Feasibility of Dynamically-Generated Textboxes

W

Will Lastname

I'm working on administration panel that will ultimately allow the
client to edit products in a collection. Each ProjectList can have
multiple products within it. I was asked to create something that will
allow them to edit the products within that list. I was thinking of
writing using a DataReader and spitting the values out into textboxes.
The only problem is that I won't know beforehand what the textboxes
would be called. In the past creating stuff like this I would know that
I needed textboxes named, tbFirstName, tbLastName, tbEmail, tbZip,
etc... This project is going to have to be more dynamic than that. If
you don't think that dynamically-generated textboxes are the best way
to go I would certainly welcome any opinions.

If you think the textbox idea would work please offer suggestions.

Thanks,

- Will
 
D

darrel

If you think the textbox idea would work please offer suggestions.

I'm not quite sure exactly what you are asking, but when I have to present a
list of multiple items to be edited and I don't know how many there will be,
I just use a string builder and write them out within loop:

count = #items

while count > 0
sb.append("<input type='text' id='textbox_" & count & "'>")
end while

-Darrel
 
W

Will Lastname

Darrel: You hit the nail right on the head. I thought about building a
string but wasn't sure how to update the database if more than 1 of the
items were edited.

strSQL as string = UPDATE SET ...

How would I tackle the issue of editing everything that was changed? In
the past I have used a boolean for bolTextBoxChanged and have it set to
false at page load. Each textbox would then have
onTextChanged=bolTextBoxChanged even that would set it to true. I still
don't know how to loop through and create the SQL statements.
 
D

darrel

Darrel: You hit the nail right on the head. I thought about building a
string but wasn't sure how to update the database if more than 1 of the
items were edited.

My way is probably not the most efficient way, but I just go ahead and loop
through each one updating the record for each. Yes, it means I'm updating
records that didn't actually have data change, so in those cases, your
method of adding another flag might work well.

-Darrel
 
W

Will Lastname

I actually got it to work today using EditCommandColumn. This way the
client can update 1 or 5 fields if they wish. I thought about doing it
your way early on but some of the projectLists can contain 100-500+
products.

Thanks again.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top