How to raise event on dynamically created textbox control in DataG

G

Guest

I have a DataGrid in which one of the columns is TemplateColumn that was
created dynamically using iTemplate. I would like to have multi-row editing
capability on the DataGrid. I'm trying to follow the example in MSDN
http://msdn.microsoft.com/library/d...QuestionsAboutASPNETDataGridServerControl.asp
Section "Editing Multiple Rows at once".

I would like to follow the second solution for the "Editing Multiple Rows at
once" which is using ArrayList to keep track of all raised events by the
textboxes on TextChanged event. However I have a problem. In the example
described in the article assumed that the TemplateColumn which contains the
textboxes was created during the Design Time, whereas my TemplateColumn was
created dynamically. How can I raise event on dynamically created controls
in DataGrid? I pasted the code from MSDN to illustrate my issue. Any help
is appreciated. Thank you

Peter

**************Pasted from MSDN**************************
One task is left: binding the handlers to the control events. In Visual
Studio, you can only do this in HTML view. The controls are not explicitly
instantiated in the code-behind file, so they are not supported by the code
tools. Switch the .aspx file to HTML view and in the declarative elements for
each of the controls, add the following highlighted syntax:

<asp:TemplateColumn HeaderText="title"> <------- I DON'T HAVE THIS
<ItemTemplate>
<asp:TextBox OnTextChanged="RowChanged"
id=TextBoxTitle runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.title") %>'>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="instock">
<ItemTemplate>
<asp:CheckBox id=cbInStock OnCheckedChanged="RowChanged"
runat="server"
Checked='<%# DataBinder.Eval(Container, "DataItem.instock") %>'>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top