HI i have above html tag in my asp.net listview item template ,
<td>
<asp:CheckBox runat="server" ID="chkStudentStatus" Text='<%# GetStatusString(Eval("StudentStatus").ToString()) %>' CommandName='<%#Eval("StudentID")%>' OnCheckedChanged="chkStudentStatus_CheckedChanged" Checked='<%#Eval("StudentStatus") %>' AutoPostBack="True" />
</td>
While check box value changed i was to get the Command Name value in the " chkStudentStatus_CheckedChanged " function
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"];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With