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.