如何在Chackboxchange事件中获取内部数据列表的Lable Id [英] How Do I Get Lable Id Which Is Inside Datalist On Chackboxchange Event

查看:94
本文介绍了如何在Chackboxchange事件中获取内部数据列表的Lable Id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Friend,



我想在CheckalChange事件中获取LableId,这是在Datalist Control中的内容

但是我没有得到它....



Html代码



 <   asp:DataList     runat   =  server    ID   =  MaterialList >  
< ItemTemplate >
< asp :标签 ID = MaterialId runat = 服务器 文本 =' <% #Eval( MaterialId%> ' < span class =code-attribute>可见 = false > < / asp:Label >
< div style = padding-bottom:5px; >
< asp:CheckBox ID = MaterialNameChk runat = server < span class =code-attribute> 文本 =' <% #Eval( MaterialName %> ' OnCheckedChanged = MaterialNameChk_CheckedChanged AutoPostBack = true / < span class =code-keyword>>
< / div >
< / ItemTemplate >
< / asp:DataList >





.cs代码< br $> b $ b

<前lang =cs> protected void MaterialNameChk_CheckedChanged( object sender,EventArgs e)
{
if (sender!= null
{
CheckBox复选框=(CheckBox)发件人;

DataListItem item =(DataListItem)checkbox.NamingContainer;
标签idlbl =(标签)item.FindControl( MaterialId);

// Reset.Text =重置;
}
}





请帮我解决这个问题...



谢谢你提前

解决方案

试试



 protected void MaterialNameChk_CheckedChanged(object sender,EventArgs e)
{
if(sender!= null)
{
CheckBox checkbox =(CheckBox)sender;
if(checkbox!= null)
{
Label idlbl = checkbox.Parent.FindControl(MaterialId)as Label;

}
}
}


Hello Friend ,

I am trying to get LableId On CheckboxChange Event which is inside the Datalist Control
But i am not getting it....

Html Code

<asp:DataList runat="server" ID="MaterialList">
                    <ItemTemplate>
                        <asp:Label ID="MaterialId" runat="server" Text='<%# Eval("MaterialId")%>' Visible="false"></asp:Label>
                        <div style="padding-bottom: 5px;">
                            <asp:CheckBox ID="MaterialNameChk" runat="server" Text='<%# Eval("MaterialName")%>' OnCheckedChanged="MaterialNameChk_CheckedChanged" AutoPostBack="true" />
                        </div>
                    </ItemTemplate>
                </asp:DataList>



.cs Code

protected void MaterialNameChk_CheckedChanged(object sender, EventArgs e)
  {
      if (sender != null)
      {
          CheckBox checkbox = (CheckBox)sender;

    DataListItem item = (DataListItem)checkbox.NamingContainer;
            Label idlbl = (Label)item.FindControl("MaterialId");

         // Reset.Text = "Reset";
}
}



Please help me out for this problem...

Thank u In Advance

解决方案

Try

protected void MaterialNameChk_CheckedChanged(object sender, EventArgs e)
 {
      if (sender != null)
      {
        CheckBox checkbox = (CheckBox)sender;    
    	if(checkbox != null)
    	{
        Label idlbl = checkbox.Parent.FindControl("MaterialId") as Label;

    	}
   }
}


这篇关于如何在Chackboxchange事件中获取内部数据列表的Lable Id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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