Retrieving hidden fields (key) when updating datagrid

  • Thread starter Thread starter KavvY
  • Start date Start date
K

KavvY

Hello,

I have managed to get to a point where clicking on the update button
retrieves the fields which are updated ok, but the field that contains the
key and is hidden is proving to be difficult.

// The following line finds nothing
String strKey = e.Item.Cells[0].Text;

// these lines are ok.
String strLink = ((TextBox)e.Item.Cells[1].Controls[0]).Text;
String strDesc = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
String strGroups = ((TextBox)e.Item.Cells[3].Controls[0]).Text;

If I make the key viewable (and hence editable) on the DataGrid, and change
the above line to retrieve the TextBox and then the text from that,
everything works great. But unfortunately this isn't really a preferable
solution!

Thanks
Rich.
 
Bam!!!

Its allways the case eh? I've been struggling with this for days and the
second you post for help you figure it out.

The line below retrieves the value of the key field! Christ only knows why
the damn books don't tell you this!
string key = dgItHotlinks.DataKeys[e.Item.ItemIndex].ToString();
 

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

Back
Top