c# - Get the value of the checked item inside the gridview -


i have gridview defined

<asp:gridview id="gv1" runat="server" autopostback="true" onselectedindexchanged="gv1_selectedindexchanged">      <columns>         <asp:templatefield>            <itemtemplate>                 <asp:checkbox id="chk1" runat="server" />                 <asp:boundfield datafield="name" headertext="name" sortexpression="name" readonly="true" />            </itemtemplate>         </asp:templatefield>      </columns> </asp:gridview> 

the code handled

protected void gv1_selectedindexchanged(object sender, eventargs e) {     foreach(gridviewrow row in gv1.rows)     {        checkbox check1 = (checkbox)row.findcontrol("chk1");        if(check1 != null && check1.checked)        {            label1.text = row.cells[1].text;        }     } } 

the desired column @ index 1

however, value not obtained.

label1.text = row.cells[1].value.tostring() 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -