i have read many forums relating to getting the value of the selected row from the gridview and setting it to a textbox, however i cannot copy the code to my project. the code i have frequently seen is:
string selectedItem = MyGridView.SelectedRow.Cells[1].Text;
textboxItem.Text = selectedItem;
However in my Vis studio, the .SelectedRow is unavailable but instead SelectedRows is available, this completely messes the code up as it cannot be compiled. Is there a reason why i cannot use Row instead of rows
any help would be much appreciated
thanks
Loading
Deepak BhatiaPosted Aug 5, 2010, 1:51 AM
Can you provide some detail what you exactly want to do.
Is it you select row, then submit the form and then access the row or when user clicks the row some opertaion is to be performed, If you can provide little details I may help you.
theLizardPosted Aug 4, 2010, 8:52 PM
int row;
int col;
in Gride.RowEnter
row = e.RowIndex;
col = e.ColumnIndex;
When you want to access the do this
DataGridViewRow dgr = dg.Rows[row];
textboxItem.Text = dgr.Cells[col].Value
There may be a better way.