datalist and AJAX update panel

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Oct 19, 2007.

  1. 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
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 19, 2007
    #1
    1. Advertising

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

    "rodchar" wrote:

    > 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
    =?Utf-8?B?U2l2YSBN?=, Oct 19, 2007
    #2
    1. Advertising

  3. 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?



    "Siva M" wrote:

    > Use the ScriptManager.RegisterAsyncPostBackControl() method instead of adding
    > the trigger to the collection.
    >
    > "rodchar" wrote:
    >
    > > 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
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 19, 2007
    #3
  4. 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.

    "rodchar" wrote:

    > 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?
    >
    >
    >
    > "Siva M" wrote:
    >
    > > Use the ScriptManager.RegisterAsyncPostBackControl() method instead of adding
    > > the trigger to the collection.
    > >
    > > "rodchar" wrote:
    > >
    > > > 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
    =?Utf-8?B?U2l2YSBN?=, Oct 19, 2007
    #4
  5. thanks for all your help, i appreciate it.
    rod.

    "rodchar" wrote:

    > 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
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 26, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nevyn Twyll
    Replies:
    8
    Views:
    1,847
  2. =?Utf-8?B?cm9kY2hhcg==?=

    datalist and ajax update panel

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 2, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    720
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 2, 2006
  3. =?Utf-8?B?cm9kY2hhcg==?=

    ajax update panel trigger

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    520
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 7, 2006
  4. GaryDean

    AJAX Update Panel w I.E.7 Problem

    GaryDean, Dec 4, 2006, in forum: ASP .Net
    Replies:
    10
    Views:
    5,018
    Steven Cheng[MSFT]
    Dec 12, 2006
  5. William LaMartin
    Replies:
    0
    Views:
    419
    William LaMartin
    May 24, 2007
Loading...

Share This Page