Hey guys, When I bind my data to the GridView, it populates the GridView with the correct number of rows from the database, but the rows are empty. Do you know how I can get the data to appear in these rows?

Please look at the attached picture to get a good idea of my issue. The Blue GridView2 is the one that is too be populated. (It is directly under the Red populated GridView1)
Here is my code:

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ListAll_dbConnectionString"].ConnectionString);
        conn.Open();
        SqlCommand command = new SqlCommand("GetSubjects", conn);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add("@CategoryNumber", SqlDbType.Int).Value = GridView1.SelectedIndex+1;
        SqlDataAdapter adapter = new SqlDataAdapter(command);
        DataSet ds = new DataSet();
        adapter.Fill(ds, "Subjects");
        DataTable dt = ds.Tables["Subjects"];
        GridView2.DataSource = ds;
        GridView2.DataBind();
        conn.Close();

Please note the image. The blue GridView2 is the one I am trying to populate.

Thanks.

I figured it out. I forgot to put the Datafield in under Data for the columns.

>Do you know how I can get the data to appear in these rows?

I think the GridView2 has a template column. Isn't it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.