asp.net - Check box inside repeater , How to get command name value in the check changed function -
hi have above html tag in 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 command name value in " chkstudentstatus_checkedchanged " function
try this:
short , simple
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 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"]; }
Comments
Post a Comment