如何在已有参数的方法中在 Popup 中显示 GridView 行?

How to Display GridView Rows in Popup Within a Method that Already has Parameters?

我正在尝试在已有参数的方法中的弹出窗口中显示 gridview 行。我将一个隐藏的 ID 字段传递给 LoadAttorneyPopup 方法,然后我想执行 PopulateAttorneyPopup 方法,但是当我添加参数以识别 GridView 时,我必须对 LoadAttorneyPopup 中的 PopulateAttorneyPopup 做些什么才能使其工作,因此 PopulateAttorneyPopup 不提供我 "No overload for method... takes 0 arguments" 错误?或者,我是不是找错了树,还有其他方法可以解决这个问题吗?

这是 GridView:

<asp:GridView ID="gvAttorneys" runat="server" HeaderStyle-Font-Size="X-small"
AutoGenerateColumns = "false" AlternatingRowStyle-BackColor = "LightGray" 
HeaderStyle-BackColor = "#7ac0da" HeaderStyle-ForeColor="Black" OnRowDeleting="gvAttorneys_RowDeleting" OnRowCommand="gvAttorneys_RowCommand">
<Columns>
    <asp:TemplateField HeaderStyle-Font-Size="Small" HeaderText="">
        <ItemTemplate>
            <asp:HiddenField ID="hdAttorneyID" runat="server" Value='<%#Bind("attorneyID") %>' />
        </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="attorneyName" HeaderText="Name of Attorney" ItemStyle-CssClass="alpsGrid" HeaderStyle-Font-Size="Small" ItemStyle-Width="300px" SortExpression="attorneyName" />
    <asp:BoundField DataField="startDate" HeaderText="Firm Start Date" ControlStyle-Width="150px" ItemStyle-Width="150px" HeaderStyle-Font-Size="Small" DataFormatString="{0:d}"/>
    <asp:BoundField DataField="cleCredit" HeaderText="Completed 3+ Hours of CLE" ControlStyle-Width="150px" HeaderStyle-Font-Size="Small"/>
    <asp:BoundField DataField="last4SS" HeaderText="Last 4 of S.S.#" ControlStyle-Width="150px" HeaderStyle-Font-Size="Small" ItemStyle-Width="300px"/>
    <asp:TemplateField ItemStyle-Width = "30px">
       <ItemTemplate>
           <asp:LinkButton ID="lnkEdit" runat="server" CommandName="EditAttorney" Text = "Edit" CommandArgument='<%# Container.DataItemIndex %>'></asp:LinkButton>         
       </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField ItemStyle-Width = "30px">
       <ItemTemplate>       
           <asp:LinkButton ID="lnkDelete" runat="server" CommandName="Delete" Text = "Delete" OnClientClick="return confirm('This will permanently remove this record: Continue?');"></asp:LinkButton>
       </ItemTemplate>
    </asp:TemplateField>
</Columns>
</asp:GridView>

下面是代码:

    protected void gvAttorneys_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "EditAttorney")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = gvAttorneys.Rows[index];
            HiddenField hdAttorneyID = row.FindControl("hdAttorneyID") as HiddenField;
            string attorneyID = hdAttorneyID.Value;
            int intAttorneyID = 0;
            if (int.TryParse(attorneyID, out intAttorneyID))
            {
                LoadAttorneyPopup(intAttorneyID);
            }
        }
    }

    private void LoadAttorneyPopup(int intAttorneyID)
    {
        ResetAttorneyPopup();

        hdAttorneyID_Popup.Value = intAttorneyID.ToString();
        if (intAttorneyID > 0)
        {
            PopulateAttorneyPopup();
        }

        popup.Show();
    }

    private void PopulateAttorneyPopup(object sender, GridViewCommandEventArgs e)
    {
            GridViewRow row = gvAttorneys.Rows[Convert.ToInt32(e.CommandArgument)];
            txtAttorneyName.Text = row.Cells[0].Text;
            txtStartDate.Text = row.Cells[1].Text;
            cblCLECompleted.Text = row.Cells[2].Text;
            txtLast4ofSS.Text = row.Cells[3].Text;
    }

感谢您的宝贵时间和协助!

protected void gvAttorneys_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "EditAttorney")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = gvAttorneys.Rows[index];
            HiddenField hdAttorneyID = row.FindControl("hdAttorneyID") as HiddenField;
            string attorneyID = hdAttorneyID.Value;
            int intAttorneyID = 0;
            if (int.TryParse(attorneyID, out intAttorneyID))
            {
                LoadAttorneyPopup(intAttorneyID,index);
            }
        }
    }

    private void LoadAttorneyPopup(int intAttorneyID,int rowIndex)
    {
        ResetAttorneyPopup();

        hdAttorneyID_Popup.Value = intAttorneyID.ToString();
        if (intAttorneyID > 0)
        {
            PopulateAttorneyPopup(rowIndex);
        }

        popup.Show();
    }

    private void PopulateAttorneyPopup(int rowIndex)
    {
            GridViewRow row = gvAttorneys.Rows[rowIndex];
            txtAttorneyName.Text = row.Cells[0].Text;
            txtStartDate.Text = row.Cells[1].Text;
            cblCLECompleted.Text = row.Cells[2].Text;
            txtLast4ofSS.Text = row.Cells[3].Text;
    }