DataGrid finding a control
- by nat
HI
I have a DataGrid (yes would be nicer if it was a gridview but nothing i can do about that)
in the itemDataBound event i am adding a hidden field into the first cell of each row
I am setting its ID based on something, and then saving its clientID in a List for later attempts to get the value from it
but try as i might i cant find anything with findcontrol
have tried
here is the itemdatabound bit
foreach(page in datasource){
HiddenField hidOrder = new HiddenField();
hidOrder.ID = "order_" + page.Id.ToString();
hidOrder.Value = page.Ordering.ToString();
e.Item.Cells[0].Controls.Add(hidOrder);
idList.Add(hidOrder.ClientID);
}
then this is a button click event..
int numRows = FrontEndDataGrid.Items.Count;
for (int i = 0; i < numRows; i++){
foreach(string hidID in idList){
HiddenField hf = FrontEndDataGrid.Items[i].FindControl(hidID) as HiddenField;
//ssadly this never finds anything
//have also tried looping around the cells for each 'row' - no luck there either
}
}
any ideas?
thanks
nat