Yet another DataGrid question

ultraman

Centurion
Joined
Dec 31, 1969
Messages
138
Location
Quebec, Canada
Hi !

I'm trying to update a table with an editable DataGrid (Edit, Update, Cancel button). In the Update event of the item, I can retreive every value by using the TableCell object (DataGridCommandEventArgs.Item). The only value I can' retreive is the one that I stored in an invisible cell.

Here's a sample code :
Code:
protected void ItemsGrid_Update(object sender, DataGridCommandEventArgs e)
{
      //We have to look for the inner control (TextBox) because we're in
      //edit mode and every cell is filled with a TextBox
      string strNumLigne = e.item.Cells[0].Controls[0].Text;
}

If the Cell is Visible, it works fine, but if it's not, I always get "". Does anybody knows how could I get the value of this invisible cell ?
 
Maybe you can grab the value of the cell in the EditCommand event. Before the edit boxes are there.

I had to do that once when I wanted the edit textboxes to retain the original value of the cells instead of coming up blank. You can't grab the original value in the Update command because it's too late.

That might help you but it might not.
 
Thanx VBAHole22 ! It works fine.

But I also discovered that if I use ReadOnly="True" in the BoundColumn tag, I can retreive the value from the Text property of the Cell object (e.item.Cells[0].Text) in the Update event. But as soon as I remove the ReadOnly property, it returns "". So since I don't want to edit this column (the whole point of making it invisible), I just used this method.
 
Back
Top