datalist and AJAX update panel

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Use the ScriptManager.RegisterAsyncPostBackControl() method instead of adding
the trigger to the collection.
 
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?
 
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.
 
Back
Top