c# - Get the cell value of a GridView row -
i using gridview - autogenerateselectbutton = "true"
select row in order column 1 cell value.
i have tried:
gridviewrow row = dgcustomer.selectedrow; textbox1.text = "cell value" + row.cells[1].text + "";
and writes "cell value" nothing else.
i able number of row (index) not cell value.
gridviewrow row = dgcustomer.selectedrow; textbox1.text = row.rowindex.tostring();
i have tried:
textbox1.text = dgcustomer.rows[row.rowindex].cells[1].text;
and still returns index row.
any other suggestions? thank you!
try changing code to
// selected row using selectedrow property. gridviewrow row = dgcustomer.selectedrow; // , respective cell's value textbox1.text = row.cells[1].text
update: (based on comment) if trying primary key value selected row alternate approach set
datakeynames="yourprimarykey"
for gridview definition can accessed code behind below.
textbox1.text = customersgridview.selectedvalue.tostring();
Comments
Post a Comment