0

My data grid is not showing up in my webpage at all.As in no table showing up. I did follow this stack question and modified some of its code to suit mine,but it's not showing at all.

here is the code for my class which is triggered by the button.

   private void LoadDataGrid()
    {
        con.Open();

        cmd = new SqlCommand(@"SELECT quotationID,quo_product
                             FROM JobQuotations
                             WHERE quo_custname = @custname", con);
        cmd.Parameters.AddWithValue("@custname",lblLoginName.Text);
        da = new SqlDataAdapter(cmd);
        dt = new DataTable();
        GridView1.DataSource = dt;
        GridView1.DataBind();
        con.Close();
    }

and I have inserted it inside the page_load

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           LoadDataGrid();
        }
    }

here is the markup:

<asp:GridView ID="GridView1" runat="server"></asp:GridView>
Community
  • 1
  • 1
rai nalasa
  • 849
  • 1
  • 12
  • 32

1 Answers1

0

You are missing da.Fill(dt);:

dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
Abdellah OUMGHAR
  • 3,627
  • 1
  • 11
  • 16