使用gridview单元上的用户控件打开ModalPopup单击

时间:2019-06-07 14:50:43

标签: c# asp.net gridview ajaxcontroltoolkit modalpopupextender

我有一个带有autogeneratecolumn true的asp.net网格视图。我想使一栏成为可单击的,并且在单击时,我想打开一个用户控制页面作为弹出窗口。但事实是,此用户控制页面应在click事件上加载,因为加载该页面需要该单元格的相应ID。

当前,我正在使用该gridview的rowDataBound事件使其可单击。但是,在单击该单元格值时,用户控件弹出窗口并未加载,这就是为什么用户控件以gridview的最后一个ID打开的原因。如何在点击事件中加载弹出窗口。

我尝试了以下代码: aspx页面:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register Src="../controls/PMMobileData.ascx" TagName="ProductMobileData" TagPrefix="uc" %>

<asp:GridView ID="grdMatchingResult" runat="server" ClientIDMode="Static" Caption="Matching Records" AutoGenerateColumns="true" CellPadding="4" CellSpacing="4" Font-Size="Small" HeaderStyle-BackColor="#cccccc" Style="margin-top: 10px;" OnRowDataBound="grdMatchingResult_RowDataBound">
        </asp:GridView>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" style="display: inline;">
            <ContentTemplate>
                <asp:Panel ID="ProcessingPanel" runat="server" Style="display: inline; max-height: 500px; overflow: auto; width: 1000px;" CssClass="modalPopup">
                    <table width="98%" style="border-collapse: collapse;" cellpadding="2">
                        <tr>
                            <td>
                                <uc:ProductMobileData ID="ProductMobileData" runat="server" />
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
                <cc1:ModalPopupExtender ID="ProcessingModalPopup" runat="server" BackgroundCssClass="modalBackground"
                    TargetControlID="HiddenBtn01" PopupControlID="ProcessingPanel" />
                <div>
                    <asp:Button runat="server" ID="HiddenBtn01" ClientIDMode="Static" Style="display: none;" />
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>

aspx.cs页面:

protected void grdMatchingResult_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(int.Parse(ddlAPI.SelectedValue) == 8)
    {
        if(e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[1].CssClass = "CellLink";
            int PID = int.Parse(e.Row.Cells[1].Text);
            int DeptID = logic.GetDeptIDByProductID(PID);
            FBGlobalFunctions.SetProductID(PID);
            e.Row.Cells[1].Attributes.Add("onClick", "javascript:$('#HiddenBtn01').trigger('click')");
        }
    }
}

如何在gridview单元格单击上加载用户控件? 任何帮助将不胜感激。 谢谢。

0 个答案:

没有答案
相关问题