HI i have above html tag in my asp.net listview item template ,
-
var item = (RepeaterItem) sender.NamingContainer;
change with:
var item = (RepeaterItem) chk.NamingContainer;
讨论(0)
-
try this:
Short and simple
Refrence
your check box
<td>
<asp:CheckBox runat="server" ID="chkStudentStatus" Text='<%# GetStatusString(Eval("StudentStatus").ToString()) %>' CommandName='<%#Eval("StudentID")%>' OnCheckedChanged="chkStudentStatus_CheckedChanged" Checked='<%#Eval("StudentStatus") %>' AutoPostBack="True" />
</td>
in code behind
protected void chkStudentStatus_CheckedChanged(object sender, EventArgs e)
{
var chk = (CheckBox)sender;
var studentID = chk.Attributes["CommandName"];
}
you can give any named attribute i.e. xyz='<%#Eval("StudentID")%>'
than
in code behind
protected void chkStudentStatus_CheckedChanged(object sender, EventArgs e)
{
var chk = (CheckBox)sender;
var studentID = chk.Attributes["xyz"];
}
讨论(0)
- 热议问题