Having problems with a gridview under an update panel using a AJAX PopupControlExtender with DynamicServiceMethod!

Last post 11-11-2009 12:01 PM by k1bagami. 1 replies.

Sort Posts:

  • Having problems with a gridview under an update panel using a AJAX PopupControlExtender with DynamicServiceMethod!

    11-11-2009, 11:22 AM
    • Member
      point Member
    • k1bagami
    • Member since 01-30-2009, 6:40 PM
    • Posts 2
    This code works until I start flipping pages and or sorting the data by column. 

    It's an ASP gridview wrapped around in an ASP update panel with triggers. The user is supposed to hover over a
    row with his or her mouse cursor and then an address displays. To do this I use an AJAX PopupControlExtender
    that dynamically fills the content inside of an ASP panel; that ASP panel appears as the user hovers over a row
    in the grid. It works fine without the update panel but I want to use the update panel.

    Comments and suggestions please.

    My ASP code:

    <asp:UpdatePanel ID="updSrchRes" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="gdvSrchRes" EventName="Sorting" />
    <asp:AsyncPostBackTrigger ControlID="gdvSrchRes" EventName="PageIndexChanging" />
    <asp:AsyncPostBackTrigger ControlID="gdvSrchRes" EventName="SelectedIndexChanged" />
    <asp:AsyncPostBackTrigger ControlID="gdvSrchRes" EventName="SelectedIndexChanging" />
    </Triggers>
    <ContentTemplate>
    <asp:GridView ID="gdvSrchRes" runat="server" OnRowDataBound="gdvSrchRes_OnRowDataBound"
    Width="100%" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
    GridLines="None" BorderStyle="None" OnPageIndexChanging="gdvSrchRes_OnPageIndexChanging"
    PagerSettings-Position="Top" OnSorting="gdvSrchRes_Sorting" OnSelectedIndexChanging="gdvSrchRes_SelectedIndexChanging">
    <RowStyle BackColor="#F8F5F5" />
    <AlternatingRowStyle BackColor="Beige" />
    <PagerStyle HorizontalAlign="Right" ForeColor="Red" />
    <Columns>
    <asp:BoundField HeaderText="Reference Number" DataField="HDR_ref_nbr" SortExpression="HDR_ref_nbr">
    <HeaderStyle HorizontalAlign="Center" />
    <ItemStyle HorizontalAlign="Center" />
    </asp:BoundField>
    <asp:BoundField HeaderText="First Name" DataField="APPL_fname" SortExpression="APPL_fname">
    <HeaderStyle HorizontalAlign="Left" />
    <ItemStyle HorizontalAlign="Left" />
    </asp:BoundField>
    <asp:BoundField HeaderText="Last Name" DataField="APPL_lname" SortExpression="APPL_lname">
    <HeaderStyle HorizontalAlign="Left" />
    <ItemStyle HorizontalAlign="Left" />
    </asp:BoundField>
    <asp:BoundField HeaderText="Policy Number" DataField="HDR_policy_nbr" SortExpression="HDR_policy_nbr"
    ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="center" />
    <asp:BoundField HeaderText="Effective Date" DataField="HDR_pol_eff_date" SortExpression="HDR_pol_eff_date"
    DataFormatString="{0:MM/dd/yyyy}" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="center" />
    <asp:BoundField HeaderText="User ID" DataField="HDR_tran_user_name" SortExpression="HDR_tran_user_name"
    ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="center" />
    <asp:BoundField HeaderText="Producer" DataField="USER_NameFull" SortExpression="USER_NameFull"
    ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="center" />
    <asp:TemplateField>
    <ItemTemplate>
    <asp:Image ID="imgLetter" runat="server" ImageUrl="~/Images/envelope.gif" />
    <ajaxToolkit:PopupControlExtender ID="popCtrlExtAddPopUp" runat="server" DynamicServiceMethod="GetDynamicContent"
    DynamicContextKey='<%# Eval("APPL_mail_addr") %>' DynamicControlID="pnlAddPopUP"
    TargetControlID="imgLetter" PopupControlID="pnlAddPopUP" Position="right">
    </ajaxToolkit:PopupControlExtender>

    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    <asp:Panel ID="pnlAddPopUP" runat="server" />
    </ContentTemplate>
    </asp:UpdatePanel>

    The C# Code:

    protected void gdvSrchRes_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {

    PopupControlExtender addPopUp = e.Row.FindControl("popCtrlExtAddPopUp") as PopupControlExtender;
    string behaviorID = string.Format("addPopUp{0}", e.Row.RowIndex);
    addPopUp.BehaviorID = behaviorID;
    string mouseOver = string.Format("$find('{0}').showPopup();{1}", behaviorID,
    "this.style.cursor='hand';this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='Lime'");
    string mouseout = string.Format("$find('{0}').hidePopup();{1}", behaviorID,
    "this.style.backgroundColor=this.originalstyle;");
    e.Row.Attributes.Add("onmouseover", mouseOver);
    e.Row.Attributes.Add("onmouseout", mouseout);
    e.Row.Attributes.Add("onClick", ClientScript.GetPostBackClientHyperlink(this.gdvSrchRes, "Select$" + e.Row.RowIndex));
    }
    }


    [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static string GetDynamicContent(string contextKey)
    {
    StringBuilder htmlBuilder = new StringBuilder();
    htmlBuilder.Append("<div>");
    htmlBuilder.Append(string.Format("<h3>{0}</h3>", contextKey));
    htmlBuilder.Append("</div>");
    return htmlBuilder.ToString();
    }




  • Re: Having problems with a gridview under an update panel using a AJAX PopupControlExtender with DynamicServiceMethod!

    11-11-2009, 12:01 PM
    Answer
    • Member
      point Member
    • k1bagami
    • Member since 01-30-2009, 6:40 PM
    • Posts 2

    I fixed the problem. I stuck the address panel outside of the update panel. It works fine now. Thanks.

Page 1 of 1 (2 items)