I am trying to retrieve the values of dynamically created controls in a Radgrid. I have read dozens of posts similar to this, but cannot seem to sort it out.
Here is the scenario:
It is the last part that has me stumped.
At first I was getting a null reference to the controls - and found that my dynamic controls where not in the GridItem container where I had created them.
After a bit of reading, I added code that loops through and re-initializes the controls in the grid. To do this I Rebind the Radgrid right before looping through the Radgrid items, setting a flag that has the code in ItemDatabound only create the Controls with the proper ID and then .Adds() them to the GridDataItem - skipping the parts that set the default values of the controls
At this point I can now get the control with .FindControl(myID) - but the .text or .selectedvalue, etc is null.
Is this kind of scenario supported with the RadGrid and AjaxManager?
Here is the scenario:
- I have a Radgrid on my page with static GridTemplateColumns setup
- In one column I have a blank ItemTemplate
- OnItemDatabound (which happens as an AJAX callback) I insert a dynamic control, and potentially set it's value (e.g. textbox, datepicker, combobox). This control type is based on the data - so I cannot do this in OnItemCreated
- Everything looks right when the screen comes back - I have a grid with custom controls in each row, and the proper values all set
- Then you do some other things on the screen - and eventually click SAVE
- On Save I loop through the Radgrid items, find the controls by ID and retrieve their values - to then save off
It is the last part that has me stumped.
At first I was getting a null reference to the controls - and found that my dynamic controls where not in the GridItem container where I had created them.
After a bit of reading, I added code that loops through and re-initializes the controls in the grid. To do this I Rebind the Radgrid right before looping through the Radgrid items, setting a flag that has the code in ItemDatabound only create the Controls with the proper ID and then .Adds() them to the GridDataItem - skipping the parts that set the default values of the controls
At this point I can now get the control with .FindControl(myID) - but the .text or .selectedvalue, etc is null.
Is this kind of scenario supported with the RadGrid and AjaxManager?