J
Jun
Hi
I am using a datalist control to display data from the database like everyone else. However I am unable to find dynamically created controls in the datalist.
Description
To simplify the use case, for every record I retrieve from the database, I display a checkbox, a hidden field containing the id of the current record, and a description of the record (Literal text). At the end of the datalist, I have a button that when clicked will call a server method that will loop thru the datalist and depending on the checkbox state, it does the appropriate database processing
When I physically design the UI in the ItemTemplate, everything works fine. I am able to loop thru the datalist items collection and within each datalistitem, I am able to do a FindControl and find the checkbox and hidden field
Problem
When I don't use the itemTemplate, but instead dynamically draw the checkbox, hidden button, and description in the datalist's ondatabind event, the method I call when I click the button is unable to find the checkbox nor the hidden button. The datalist draws fine. The result seems to be identical to the result I get when I physically design the UI. Everything works fine except for the method not being able to find the controls
did I miss something
Thanks
jun
I am using a datalist control to display data from the database like everyone else. However I am unable to find dynamically created controls in the datalist.
Description
To simplify the use case, for every record I retrieve from the database, I display a checkbox, a hidden field containing the id of the current record, and a description of the record (Literal text). At the end of the datalist, I have a button that when clicked will call a server method that will loop thru the datalist and depending on the checkbox state, it does the appropriate database processing
When I physically design the UI in the ItemTemplate, everything works fine. I am able to loop thru the datalist items collection and within each datalistitem, I am able to do a FindControl and find the checkbox and hidden field
Problem
When I don't use the itemTemplate, but instead dynamically draw the checkbox, hidden button, and description in the datalist's ondatabind event, the method I call when I click the button is unable to find the checkbox nor the hidden button. The datalist draws fine. The result seems to be identical to the result I get when I physically design the UI. Everything works fine except for the method not being able to find the controls
did I miss something
Thanks
jun