//Retrieving more than one table from DB using DataSet protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { dataset.Clear(); var con = new SqlConnection(connectionString); var command = new SqlCommand("MultiRecordSet", con); command.CommandType = CommandType.StoredProcedure; con.Open(); var adapter = new SqlDataAdapter(command); adapter.Fill(dataset); con.Close(); if (dataset.Tables.Count > 0) { GridViewRecordSet.DataSource = dataset.Tables[0]; GridViewRecordSet.DataBind(); } else { Response.Write("No table found"); } } }
protected void Table3_Click(object sender, EventArgs e) { GridViewRecordSet.DataSource = dataset.Tables[2]; GridViewRecordSet.DataBind(); }