Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
Dynamically created webcontrol's events not firing
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Mark Rae, post: 480964"] Hi, I'm sure I've done this before, but I can't get it to work today... I'm trying to add a DropDownList into a TableCell and wire up its SelectedIndexChanged event. I'm adding the dynamic control like this: mtblCell = new TableCell(); mtblCell.ColumnSpan = 2; DropDownList cmbShipping = new DropDownList(); cmbShipping.Items.Add(new ListItem("", "0")); cmbShipping.Items.Add(new ListItem("United Kingdom", "1")); cmbShipping.Items.Add(new ListItem("European Union", "2")); cmbShipping.Items.Add(new ListItem("Rest of world", "3")); cmbShipping.AutoPostBack = true; cmbShipping.SelectedIndexChanged += new EventHandler(cmbShipping_SelectedIndexChanged); mtblCell.Controls.Add(cmbShipping); mtblRow.Cells.Add(mtblCell); I've already created the code for the event: private void cmbShipping_SelectedIndexChanged(object sender, EventArgs e) { BindData(); } It all seems to work well enough inasmuch as the DropDownList certainly does get created in the TableCell - the resulting HTML looks like this: <td colspan="2"> <select name="_ctl0" onchange="__doPostBack('_ctl0','')" language="javascript"> <option value="0"></option> <option value="1">United Kingdom</option> <option value="2">European Union</option> <option value="3">Rest of world</option> </select> </td> When I change the selected index of the DropDownList, it does the postback as expected. However, the cmbShipping_SelectedIndexChanged event doesn't fire. I must be missing something totally obvious. Any assistance gratefully received. Mark [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
Dynamically created webcontrol's events not firing
Top