I have a textbox for quantity,Label drop downlist for different Products.I have a Place holder. and a a ok button. if i give a value of quantity 3 and selct a product suppose mouse the 3 labels with name mouse with 3 text boxes appearing. My problem is i have to display the mouses as mouse1 mouse2 mouse3.how will i do please help.
My code is
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
for (int i = 0; i < Convert.ToInt16(TextBox1.Text); i++)
{
Label la = new Label();
la.Text = DropDownList1.SelectedItem.Value;
la.ID = "abc" + i.ToString();
PlaceHolder1.Controls.Add(la);
//la = FindControl(String.Format(i)) as Label;
TextBox tb1 = new TextBox();
tb1.ID = "ghj" + i.ToString();
PlaceHolder1.Controls.Add(tb1);
PlaceHolder1.Controls.Add(new LiteralControl("
"));
}
}
}
My code is
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text != "")
{
for (int i = 0; i < Convert.ToInt16(TextBox1.Text); i++)
{
Label la = new Label();
la.Text = DropDownList1.SelectedItem.Value;
la.ID = "abc" + i.ToString();
PlaceHolder1.Controls.Add(la);
//la = FindControl(String.Format(i)) as Label;
TextBox tb1 = new TextBox();
tb1.ID = "ghj" + i.ToString();
PlaceHolder1.Controls.Add(tb1);
PlaceHolder1.Controls.Add(new LiteralControl("
"));
}
}
}