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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redundant controls, array?

Status
Not open for further replies.

influent1

Programmer
Sep 20, 2004
10
US
I'm working on a form that will have several textboxes for each item entered, e.g. item#, description, size, etc., for up to ten items, so let's say 8 textboxes per item for a total of 80 on the form. I'd like to be able to do something like a repeater and/or a control array so that I can dynamically declare and access the textboxes. Is there a good way to do this?
 
You can store the data into a hashtable and bind the hanshtable to a repeater control

good luck


Note:Copying and Pasting is NoT Creativity.
What would you attempt to accomplish if you knew you would not fail?
 
I think I thought of a good solution. I'll turn each item group (eight textboxes) into one ascx class. That should be a lot easier if it works the way I think it will.
 
you can use a placeholder and add the items dynamically at run time to it. then loop through all the controls in the placeholder and retrieve the values you need.

also you can have multiple placeholders (one for each item entered) and in each, create the texboxes above (this is merely to make things cleare when looping through the controls)

your sollution might work as well

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
My solution works, but when selecting items in the dropdowns I put in the ascx files, it's quite slow. And the dropdowns are only date selectors (month, day, year), so it's not even like they have a long list of values. Maybe it's the viewstate that's slowing it down, I have no idea.
 
The slowness was just temporary, but now I'm having problems accessing variables from user controls. I have one ascx inside another inside the aspx page, and I can access variables in the outer one (e.g. ascx1.table1.color=red) but not in the inner ascx (e.g. ascx1.ascx2.textbox1="text"). What's the trick? All my variables are public, and the autocompletion shows everything I need, but either nothing happens or I get "object reference not set to an instance of an object" when the page posts back.
 
try to do this accessing in some later event (like OnBeforeRender)

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top