I'm not able to display the selected gridview row's column data into the textbox. I have a select column at my gridview. The selected row to be displayed is already declared as a string.
Code :
tbpolicereport.Text = GVStatusReportPolice.SelectedRow.Cells[2].Text;
Update :
The above code is correct. This code is used when you bind your gridview with the sql server through the sqldatasource. the cell number is just the column number you would like to display out.
After debugging, i realized that the value did pass through however it wasn't able to be display out on my textfield. After re-creating the entire form, the value appears magically.
You need to specify the row and column indexes..
The Value can be taken like this:
int rowindex = GVStatusReportPolice.CurrentCell.RowIndex;
int columnindex= = GVStatusReportPolice.CurrentCell.ColumnIndex;
lblCID.Text = GVStatusReportPolice.Rows[rowindex].Cells[columnindex].Value.ToString();
Try this ..
tbpolicereport.Text = GVStatusReportPolice.Currentcell.Value;
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