0

Using SPGridView, I want to fill textboxes with the SPGridview Selected Row Data on a button click event.

txtCode= SPGridView.SelectedRow.Cell[1].Text;

On debugging, it shows Cell[1] is empty but it is showing data in the Grid.

How can this be achieved?

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Saad
  • 1,312
  • 5
  • 17
  • 40

2 Answers2

2

I've just got similar problem. And I've find out that "selectedvalue" is solution. so try :

txtCode.Text = Convert.ToString(oSPGridView.SelectedValue);
danan
  • 441
  • 4
  • 4
1

Remember that cell index start at 0.

you can also try this

((TextBox)SPGridView.Rows[SPGridView.SlectedIndex].Cells[1].Controls[0]).Text;
Gui Ferreira
  • 4,367
  • 6
  • 28
  • 41