CoolDev2014
asked on
asp.net placeholder from db
i have table like
ID PlaceHolder Desc
1 TextBox VIN
2 Radio Button Yes/No
In the frontend, I can query but I don't know how to dynamically create user control.
Like if it is textbox, it will create a textbox. I am thinking using Place Holder but I don't know how to implement that.
Let assume we already done the frontend, I need to find a way to capture data and save into the database. I can handle the SQL part but I don't know how to capture the data in a FOR loop.
Thanks, and see any experts can help.
ID PlaceHolder Desc
1 TextBox VIN
2 Radio Button Yes/No
In the frontend, I can query but I don't know how to dynamically create user control.
Like if it is textbox, it will create a textbox. I am thinking using Place Holder but I don't know how to implement that.
Let assume we already done the frontend, I need to find a way to capture data and save into the database. I can handle the SQL part but I don't know how to capture the data in a FOR loop.
Thanks, and see any experts can help.
ASKER
Thank but hoping to get coding sample from my example.
What you're attempting to do is not a trivial thing. It all depends on your architecture and how you've laid everything out. Your question was how do you loop over each control in the place holder . . . that's done in the foreach loop. What you do with it from there can vary on your requirements.
If you have specific questions relating to something in your code, I'd be happy to help.
If you have specific questions relating to something in your code, I'd be happy to help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hey, Have you tried the above solution ?
This shows the general setup:
http://forums.asp.net/t/1807044.aspx?Find+dynamically+added+controls+to+Panel+in+ASP+NET+using+C+
You can add each control (rather than just a label) based on the type.
Note you may want to add a parentControl to each control.
For instance:
Your Radiobutton should be a radiobuttonlist with a controlId
then your radiobuttonlist should have the 2 radiobuttons (yes / no). This way you can have other controls in there.
To iterate over the controls:
(foreach Control c in Panel1.Controls)
//note that c. can have it's own controls, you'll need to loop through those as well.
the last piece is tying that to the DB . . . I usually recommend using some other attribute of the control (say tag for instance) to store the field. You can then build your sql statements from that.
This is high level for now . . . if you need a clearer picture at the details feel free to ask.