Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display gridview value into textbox

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.

like image 609
Bryan Avatar asked Jan 21 '26 22:01

Bryan


2 Answers

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();
like image 170
Milen Avatar answered Jan 24 '26 18:01

Milen


Try this ..

tbpolicereport.Text = GVStatusReportPolice.Currentcell.Value;
like image 37
matzone Avatar answered Jan 24 '26 18:01

matzone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!