Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Dropdownlist in table control

Status
Not open for further replies.

gmcevoy

Programmer
Aug 13, 2002
10
CA
I build a table on the fly using a table control. On the table control I add a textbox, 2 labels and a dropdownlist. When the selected item in the dropdownlist is changed I need to read that event. The problem being is because the dropdown box was built dynamically there is no known name for the combo box.

There could be as few as 10 combo boxes and as many as 200 hundred. Depending on what is in the database.

Hope this makes sense.
 
If you are building your controls in the code behind, you can assign the id to each control programatically. I would assume you are running some sort of loop to create the controls so just name the controls something like:

listcontrol.id = "lst" & loopCounter

also, set the autopostback to true

listcontrol.autopostback = true

then add a handler for each control

AddHandler controlname.eventname, Addressof HandlerName

where handlername is the function or sub in your codebehind

Then, in the handler you could do something like this:

for intI = 0 to Request.Form.Keys.Count -1
this will loop through the controls
Request.Form.Keys(intI) will return the id that you
assigned dynamically.

next

 
Zombie you missed a couple of steps, I have figured it out and had what you wrote when I posted this as well. What also has to be done is every cell and row id has to be set in the server table control as well. This is what I was missing. As soon as I add that it worked fine. What you wrote works if you are just dumping it on the screen, the table control added a new dimension to it.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top