I am trying to add some TextBoxes
controls dynamically based on items in my database. This is my asp:PlaceHolder
in .aspx
page
<asp:PlaceHolder ID="PlaceHolderHTML" runat="server"></asp:PlaceHolder>
and now from C# code I am trying to create dynamic HTML
and then that html render to asp:PlaceHolder
.
This is my C# code:
StringBuilder data = new StringBuilder();
foreach (SPListItem item in collitem)
{
data.Append(@"
<tr>
<th class='accordionSection esEmplCardSectionHeader'>
<span id='lblSectionName'>
<asp:TextBox ID='TextBox" + item["ID"].ToString() + @"' runat='server'></asp:TextBox>
</span>
</th>
</tr>
}
PlaceHolderHTML.Controls.Add(new Literal { Text = data.ToString() });
but in browser the TextBox
controls are not being shown. When I inpect element the textbox I am seeing the following result:
So the textbox
inside html that is being sent to asp:PlaceHolder
, browser is not knowing it as asp control and in the browser nothing is being shown, so how to solve this problem?
Aucun commentaire:
Enregistrer un commentaire