Click to See Complete Forum and Search --> : How can I get Value from selected row in datagrid


jonhsv
February 11th, 2003, 09:57 AM
Hello Everyone

I have been trying to get the value from selected row in Datagrid for ASP.NET, I have been looking everywhere for some code but without result, how can I do this

Thanks in Advance


Jon Sveinsson

mikescham
February 13th, 2003, 04:45 PM
I haven't used the datagrid in this way yet but this will probably work:

TextBox txt = (TextBox)dg.Items[dg.SelectedIndex].Controls[myTextID];

string val = txt.Text;

(where dg is a reference to your datagrid)

guyute618
February 24th, 2003, 02:13 AM
if you're working with VB this should work
Dim GridValue as string = CType(e.Item.Cells(0).Controls(0), TextBox).Text

GridValue being the variable for the new value you're trying to get. e.Item.Cells(0) the number within those paranthesis corresponds to column you're trying to get to.


hope this helps

guyute