c# - Gridview Get Cells ID -


i want select gridview id. code below. can achieve this?

 protected void gridview1_selectedindexchanged(object sender, eventargs e)  {      int id = convert.toint32(gridview1.selectedrow.cells[0].tostring());      textbox2.text = id.tostring();  }  

check , may work u ,call cell id directly.

 this.gridview1.cellclick += new system.windows.forms.gridviewcelleventhandler(this.gridview1_cellclick); private void gridview1_cellclick(object sender, datagridviewcelleventargs e) {   try   {     string id = gridview1.rows[gridview1.currentrow.index].cells["id"].value.tostring();     textbox1.text = id;   }   catch (exception)   {   } } 

or change in ur code..

string id = gridview1.rows[gridview1.currentrow.index].cells[0].value.tostring();   textbox1.text = id; 

add this...

  <asp:templatefield>    <itemtemplate>   <asp:checkbox id="chksec" runat="server" autopostback="true" oncheckedchanged="chksec_checkedchanged1" />   </itemtemplate>    </asp:templatefield>    protected void chksec_checkedchanged1(object sender, eventargs e) {     response.write("checkbox checked"); } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -