在后端获取不到GridView的行数据

前端GridView里的内容,在后端Click事件里获取不到


```c#
  <asp:GridView ID="DgView" runat="server" CssClass="grid_view" AutoGenerateColumns="False"
                    Width="100%" OnRowDataBound="DgView_RowDataBound">
                    <EmptyDataTemplate>
                        无相关数据
                    </EmptyDataTemplate>

protected void btnPrint_Click(object sender, EventArgs e)
    {
        string px = "";
        if (DgView.Rows.Count > 0)
        {
            if (DgView.Rows[0].Cells.Count > 0)
            {
                px = DgView.Rows[2].Cells[2].Text.ToString();
                if (px == "1")
                {
                    PageHelper.RunJs(this, "OpenPrint2()");
                }
                else
                {
                    PageHelper.RunJs(this, "OpenPrint1()");
                }
            }
        }
    }

```

px = DgView.Rows[2].Cells[2].Text.ToString() 这句执行了吗,如果没执行看是那个没满足?

问了技术主管,已经解决问题了,gridview里的属性会影响传值,


```c#
 protected void btnPrint_Click(object sender, EventArgs e)
    {
        string px = ((Button)sender).CommandArgument;
        
        if (DgView.Rows.Count > 0)
        {
            if (DgView.Rows[0].Cells.Count > 0)
            {
                if (px == "1")
                {
                    PageHelper.RunJs(this, "OpenPrint2()");
                }
                else
                {
                    PageHelper.RunJs(this, "OpenPrint1()");
                }
            }
        }
    }

```