How to Create Label Dynamic Fields Based On DropDownlist

Jayakumars
Posted by Jayakumars under ASP.NET AJAX category on | Points: 40 | Views : 1046
How to Create Label Dynamic Fields Based On DropDownlist
========================================
protected void Bt1_Click(object sender, EventArgs e)
{

Drp1.Items.Add(TxtField.Text);

}
protected void Bt2_Click(object sender, EventArgs e)
{

for (int i = 0; i < Drp1.Items.Count; i++)
{
Label lbl1 = new Label();
lbl1.Text = Drp1.Items[i].Text;
lbl1.ID = "lbl1" + i;
form1.Controls.Add(lbl1);
}

<asp:TextBox ID="TxtField" runat ="server" ></asp:TextBox>
<asp:Button ID="Bt1" runat ="server" Text ="submit1" onclick="Bt1_Click" />
<br />
<br />
<asp:DropDownList ID="Drp1" runat ="server" >
</asp:DropDownList>
&nbsp;<asp:Button ID="Bt2" runat ="server" Text ="submit1" onclick="Bt2_Click"
/>
<br />
<br />

Comments or Responses

Login to post response