datalist and AJAX update panel

G

Guest

hey all,
i have a datalist which contains linkbuttons. i'd like to add the
LinkButton_click event to the update panel triggers. I'm assuming i have to
do this in the code-behind and here's what i have so far and my best guess
but still posts back:

protected void DataList1_ItemDataBound(object sender,
DataListItemEventArgs e)
{
UpdatePanel updPanel =
(UpdatePanel)this.form1.FindControl("UpdatePanel1");
LinkButton lnkButton = (LinkButton)e.Item.FindControl("LinkButton1");
AsyncPostBackTrigger trg = new AsyncPostBackTrigger();
trg.ControlID = lnkButton.ClientID; //also tried .ID
trg.EventName = "Click";
updPanel.Triggers.Add(trg);


}

thanks,
rodchar
 
G

Guest

Use the ScriptManager.RegisterAsyncPostBackControl() method instead of adding
the trigger to the collection.
 
G

Guest

which control do i add as the parameter? it won't let me add the trigger. i
tried adding the linkbutton but it didn't work. am i doing all this in the
wrong event?
 
G

Guest

Add the LinkButton instance with the RegisterAsyncPostBackControl(). Also, I
hope you have set UpdateMode="Conditional" for the ScriptManager and call
UpdatePanel.Update() in the click event of the LinkButton.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top