netformx
asked on
load control dynamically in the table
Hi,
I have table that looks:
Label textbox
Label textbox
I want to load label and textbox dynamically.
I put 2 PlaceHolders :
<TR>
<TD>
<asp:PlaceHolder id="PlaceHolder_Labels" runat="server"></asp:Place Holder></T D>
<TD>
<asp:PlaceHolder id="PlaceHolder_Values" runat="server"></asp:Place Holder></T D>
</TR>
but when I add to PlaceHolder.Controls it looks:
Label1Label2 textbox1textbox2
and I need:
Label1 textbox1
Label2 textbox2
How to achive that?
I have table that looks:
Label textbox
Label textbox
I want to load label and textbox dynamically.
I put 2 PlaceHolders :
<TR>
<TD>
<asp:PlaceHolder id="PlaceHolder_Labels" runat="server"></asp:Place
<TD>
<asp:PlaceHolder id="PlaceHolder_Values" runat="server"></asp:Place
</TR>
but when I add to PlaceHolder.Controls it looks:
Label1Label2 textbox1textbox2
and I need:
Label1 textbox1
Label2 textbox2
How to achive that?
Try adding a label between the two textboxes where the label has a value of <BR>.
Else a better way would be to create a small table and add the textboxes to the table rows and add the table to the placeholder.
Else a better way would be to create a small table and add the textboxes to the table rows and add the table to the placeholder.
ASKER
with <BR> it does not look well (since text box is of 4 rows and label should be in the middle of it - when it's in table it looks OK.
can you write the simple example how to create a small table + then iterate on labels and values and fill values,
I can think of the follwoing:
add :
<TR>
<TD>
LABEL
</TD>
to PlaceHolder_Labels.Control s
and add
<TD>
textbox
</TD>
</TR>
to PlaceHolder_TextBoxes.Cont rols
iteration:
for(int i=0; i<PlaceHolder_Labels.Contr ols.Count; i++)
{
if (PlaceHolder_Labels.Contro ls[i] is Label)
myTextBox = PlaceHolder_Vals.Controls[ i-1] //i-1 becasue of table
}
but it's seems very clumsy to me, maybe you can suggest more elegant way?
can you write the simple example how to create a small table + then iterate on labels and values and fill values,
I can think of the follwoing:
add :
<TR>
<TD>
LABEL
</TD>
to PlaceHolder_Labels.Control
and add
<TD>
textbox
</TD>
</TR>
to PlaceHolder_TextBoxes.Cont
iteration:
for(int i=0; i<PlaceHolder_Labels.Contr
{
if (PlaceHolder_Labels.Contro
myTextBox = PlaceHolder_Vals.Controls[
}
but it's seems very clumsy to me, maybe you can suggest more elegant way?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks, it worked great!
Literal lit = new Literal();
lit.Text = "<br>";
PlaceHolder_Labels.Control
PlaceHolder_Labels.Control
PlaceHolder_Labels.Control
PlaceHolder_Values.Control
PlaceHolder_Values.Control
PlaceHolder_Values.Control