I have a gridview that is being populated from a dataset which is a table returned from a stored procedure. However now the stored procedure has changed and it returns 2 tables, the first returns the column headers as well as labels and other info, the second is the table with the actual data to be displayed in the gridview. I was just wanting to know how I can use the first table to get the gridview column headers and then use the second to populate the gridview. At the minute the code I have to populate the gridview is
protected void getGrid(object sender, EventArgs e)
{
SqlCommand sql = new SqlCommand("store_proc");
sql.Parameters.AddWithValue("@name", name);
sql.Parameters.Add(new SqlParameter()
{
ParameterName = "RETURN_VALUE",
Direction = ParameterDirection.ReturnValue
});
var dataset = conn.SPExecuteDataSet(sql);
int returnNumber = (int)sql.Parameters["RETURN_VALUE"].Value;
if (dataset.Tables[0].Rows.Count > 0)
{
datasource = dataset.Tables[0];
if (returnNumber == 0)
{
GridView1.DataSource = datasource;
GridView1.DataBind();
}
else
{
Label1.Text = "No access";
}
}
else
{
GridView1.DataSource = dataset;
GridView1.DataBind();
}
}