在数据列表中查找控件的ID [英] finding id of a control in a datalist

查看:77
本文介绍了在数据列表中查找控件的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据列表,如下所示

i have a datalist as follow

<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" style="z-index: 108; left: 733px; position: absolute; top: 72px" >
          <ItemTemplate><asp:Image ID="uximage" runat="server" /></ItemTemplate>
        </asp:DataList>



我想在该数据列表中找到图像控件的ID.
为此,我已将代码编写为(在按钮单击事件中)

as



i want to find id of the image control in that datalist.
for that i have written code as (in button click event)

as

protected void Button4_Click(object sender, EventArgs e)
   {





foreach(DataListItem item in DataList1.Items)
{
Image im = (Image)item.FindControl("uximage");
im.ImageUrl = "Handler.ashx";
}


}

当我执行应用程序并单击按钮时,查看所有图像
.它没有通过foreach的主体.
另外,当我放置一个断点并检查DataList1.Items时,它的计数也显示为0.
该代码有什么问题,请帮助


}

When i execute the application and when i click on button view all image
.it is not going through the body of foreach .
also when i put a break point and checked the DataList1.Items it is showing the count as 0.
what is wrong in this code ,please help

推荐答案

您尝试从Datalist的ItemCommand事件中执行代码.
Did you try executing your code from within the Datalist''s ItemCommand event.


这篇关于在数据列表中查找控件的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆