ASP.NET C#GridView中没有行?

时间:2016-11-14 22:38:18

标签: c# asp.net gridview

我有一个名为DGV_Pay1的GridView(带一个单选按钮),数据集为DataSource。

GridView的定义:

<asp:GridView ID="DGV_Pay1" runat="server" CssClass="table table-striped" AutoGenerateColumns="false" 
                           AllowPaging="false" EnableViewState="false" >
                          <Columns>
                              <asp:TemplateField>
                                  <ItemTemplate>
                                      <asp:RadioButton ID="radioPay1" runat="server" />
                                      <asp:HiddenField ID="radioPay1Value" runat="server" Value='<% Eval("ID") %>' />
                                  </ItemTemplate>
                              </asp:TemplateField>
                              <asp:BoundField DataField="NOME" HeaderText="Fee name" />
                              <asp:BoundField DataField="TOTALE" HeaderText="Total" />
                              <asp:BoundField DataField="VALIDA_AL" HeaderText="Expiry date" />
                          </Columns>
</asp:GridView>

绑定DataSet的方法:

protected void Pay1_On(object sender, EventArgs e)
    {
        NascondiPanel();
        DataSet ds = new DataSet();

        try
        {
            ds = SQLManager.GetTariffeEvento(ev.id, 1);
        }
        catch(Exception ex)
        {
            panelGeneral.Visible = false;
            panelError.Visible = true;
            lbErrore.Text = ex.Message;
            return;
        }

        DGV_Pay1.DataSource = ds;
        DGV_Pay1.DataBind();
        PanelPay1.Visible = true;

    }

执行后,我在GridView中有一行 但是当我选择单选按钮并按下提交按钮时,以下方法不会检测到任何行...

protected void Submit(object sender, EventArgs e)
    {
        [...]

        int tariffa = -100;
        if(Pay1.Checked) //Yes, it's checked! It's a radio out the GridView...
        {
            for (int i = 0; i < DGV_Pay1.Rows.Count; i++)
            {
                [...]
            }


        }

      [...]

    }

任何想法?
感谢...

0 个答案:

没有答案