0

I have a GridView from where I want to get a text value from cell in column 26 in the selected row into an TextBox (named txtResult). Cell is not visible (its Visible property is false).

I tried this:

txtResult.Text = grdMyGrid.SelectedRow.Cells[26].Text;

Thanks for your help in advance!

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
RMU
  • 37
  • 3
  • 8
  • Do you have `TemplateFields` or `BoundsFields`? If the former, show your aspx especially the controls. – Tim Schmelter Sep 03 '13 at 20:27
  • so,what is the problem? – ridoy Sep 03 '13 at 20:31
  • I can get the text when I do Visible=true, but i can get the Value on Visible=false – RMU Sep 03 '13 at 20:52
  • Does this helps [How to hide a column (GridView) but still access its value?](http://stackoverflow.com/questions/5376278/how-to-hide-a-column-gridview-but-still-access-its-value)? – Chris Sep 03 '13 at 21:48

2 Answers2

0

Don't set the invisibility on the regular column properties on the code behind (.aspx), do it throught the RowDataBound event. I believe this way you will get the value.

Hugo Hilário
  • 2,848
  • 2
  • 27
  • 43
0

You'll better try this code:

dataGridView1.SelectedRows[0].Cells["ColummName"].Value.ToString();
juhan_h
  • 3,965
  • 4
  • 29
  • 35
MAHSA
  • 1