i need some more help on ths. with runtime addition of textbox i need to add delete button, on click of tht button textbox with label shud get delete.
i have added a button on runtime ..but how can i delete the runtime textbozx?? plz luk into ths
here is my code:
public static int count = 3;
public int i = 0;
protected void btnDelete_click(object sender, EventArgs e)
{
panelId.Controls.Clear();
for (i = 0; i < count; i++)
{
Label l1 = new Label();
if (i % 3 == 0)
{
l1.Text = "first";
Literal lt1 = new Literal();
lt1.Text = "<br />";
}
if (i % 3 == 1)
{
l1.Text = "second";
}
if (i % 3 == 2)
{
l1.Text = "third";
}
l1.ID = "lbl" + i;
TextBox t1 = new TextBox();
t1.ID = "txt" + i;
Literal lt = new Literal();
lt.Text = "<br />";
panelId.Controls.Add(lt);
panelId.Controls.Add(l1);
panelId.Controls.Add(t1);
Response.Write(panelId.Controls.IndexOf(t1));
lt.Text = "<br />";
Response.Write(panelId.Controls.IndexOf(l1));
}
count += 3;
Button btn1 = new Button();
btn1.ID = "btn" + i;
btn1.Text = "Delete";
btn1.Click += new EventHandler(btnDelete_click);
panelId.Controls.Add(btn1);
}
protected void btnDelete_click(object sender, EventArgs e)
{
// code to delte the last set of 3 textbox wid thr label }
Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator