E
ed
Hello All.
Scenario: I have a web form with a textbox, a button and a datalist (lets
call it datalist1), when the user clicks in the button I add items to the
datalist1 as much as the textbox says. Each item in datalist1 has a label, a
link button and other datalist (datalist2), the label shows the item index,
and above the datalist2 I have a link button intended to add items to the
datalist2. I successfully can add items to the datalist1 when clicking the
button, but when clicking the Add linkbutton nothing happens. I subscribed
the onclick event by getting a reference to the button in the ItemDataBound
event in datalist1.
private void datalist1_ItemDataBound(object sender, DataListItemEventArgs e)
{
LinkButton lnkAdd = (LinkButton)e.Item.FindControl("lnkAdd ");
lnkAdd.Click += new EventHandler(lnk_Click);
}
private void lnkAdd _Click(object sender, EventArgs e)
{
// This never executes…
}
Is this way right to subscribe the event to the "add" button? What can be
the cause of this?
Thank you very much
Scenario: I have a web form with a textbox, a button and a datalist (lets
call it datalist1), when the user clicks in the button I add items to the
datalist1 as much as the textbox says. Each item in datalist1 has a label, a
link button and other datalist (datalist2), the label shows the item index,
and above the datalist2 I have a link button intended to add items to the
datalist2. I successfully can add items to the datalist1 when clicking the
button, but when clicking the Add linkbutton nothing happens. I subscribed
the onclick event by getting a reference to the button in the ItemDataBound
event in datalist1.
private void datalist1_ItemDataBound(object sender, DataListItemEventArgs e)
{
LinkButton lnkAdd = (LinkButton)e.Item.FindControl("lnkAdd ");
lnkAdd.Click += new EventHandler(lnk_Click);
}
private void lnkAdd _Click(object sender, EventArgs e)
{
// This never executes…
}
Is this way right to subscribe the event to the "add" button? What can be
the cause of this?
Thank you very much