Problem handling event in a button inside a Datalist

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top