another simple datagrid question

G

Guest

how can i get the value from a specific column from the selected row of a
datagrid

in the sub i can get the datakey for item command
Me.dgMems.DataKeys(e.Item.ItemIndex) will get me the key field, but what if
i want the value of column(2). I get nothing when i use
Me.dgMems.Columns(2).ToString(). View state is on.

thanks
(and i hope i don't have to refill the dataset on each select!)
kes
 
G

Grant Merwitz

If you use the OnItemCommand, you can pickup the value quite easily using
e.Item.Cells[2].Text;
or
((TextBox)e.Items.FindControl("tb")).Text; //If it is not a
<Asp:BoundColumn you'll need to cast it

HTH
 
A

Alex D.

try this (assuming Label is the first control and language c#):

string the_value = (MyRow.Cells[2].Controls[0]) as Label.Text;
 
G

Guest

thanks everyone,
i knew it just had to be simple!

--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes


Grant Merwitz said:
If you use the OnItemCommand, you can pickup the value quite easily using
e.Item.Cells[2].Text;
or
((TextBox)e.Items.FindControl("tb")).Text; //If it is not a
<Asp:BoundColumn you'll need to cast it

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top