By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,190 Members | 1,412 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,190 IT Pros & Developers. It's quick & easy.

How to raise event on dynamically created textbox control in DataG

P: n/a
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
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


**************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
<asp:TextBox OnTextChanged="RowChanged"
id=TextBoxTitle runat="server"
Text='<%# DataBinder.Eval(Container, "DataItem.title") %>'>

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

Nov 10 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.