I want to generate TextBoxes in my ASP.NET webpage. It works fine
foreach (var Field in db.A_Settings)
{
TextBox t = new TextBox();
t.ID = Field.ID.ToString();
t.CssClass = "smallinput";
t.Text = Field.Text;
LabelPlaceHolder.Controls.Add(t);
}
And it nicely generates something like this:
<input name="ctl00$ContentPlaceHolder1$1" type="text" value="ValueA" id="ContentPlaceHolder1_1" class="smallinput">
<input name="ctl00$ContentPlaceHolder1$2" type="text" value="ValueB" id="ContentPlaceHolder1_4" class="smallinput">
<input name="ctl00$ContentPlaceHolder1$3" type="text" value="ValueC" id="ContentPlaceHolder1_5" class="smallinput">
It is correct, but in fact I want to wrap it with some HTML, like
<p>
<label>Label for the first TextBox obtained from database</label>
<span class="field">
<input name="ctl00$ContentPlaceHolder1$1" type="text" value="ValueA" id="ContentPlaceHolder1_1" class="smallinput">
</span>
</p>
I couldn't found how to do it this way, so I was thinking about putting it into List<TextBox>, but I'm stuck here either (the same problem - no idea how to wrap the object with HTML).
Is there any way to do this?
For any posts like "Why don't you add those TextBoxes manually?" I'll send a photo of me hitting my head at keyboard, while there will be a dump of SQL with dozens of fields that needs to be handled displayed on the screen :)
Or a photo of a lemur. Lemurs are okay, too