0

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.

Edited by arelius: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by __avd
0

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

0

>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?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.