i got answer to my question
public void view_load_lkg_to_seventh()
{
//this code for auto resize of columns
dataGridView1.AutoResizeColumns();
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
ConnectionStringSettings consettings = ConfigurationManager.ConnectionStrings["smssms"];
string connectionString = consettings.ConnectionString;
SqlConnection cn = new SqlConnection(connectionString);
SqlCommand sqlcmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
cn.Open();
//pass query
sqlcmd = new SqlCommand(@"select * from lkg_to_seventh_marks ", cn);
da = new SqlDataAdapter(sqlcmd);
//Fill the data in the SQL Data Adapter
da.Fill(dt);
//Bind it in the DataGrid View
dataGridView1.DataSource = dt;
cn.Close();
}
public void view_load_tenthclass_marks()
{
//this code for auto resize of columns
dataGridView3.AutoResizeColumns();
dataGridView3.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
ConnectionStringSettifdgngs consettings = ConfigurationManager.ConnectionStrings["smssms"];
string connectionString = consettings.ConnectionString;
SqlConnection cn = new SqlConnection(connectionString);
SqlCommand sqlcmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
cn.Open();
//pass query
sqlcmd = new SqlCommand(@"select * from tenthclass_marks ", cn);
da = new SqlDataAdapter(sqlcmd);
//Fill the data in the SQL Data Adapter
da.Fill(dt);
//Bind it in the DataGrid View
dataGridView3.DataSource = dt;
cn.Close();
}
private void tabControl1_Click(object sender, EventArgs e)
{
if
(tabControl1.SelectedTab == tabPage2)
{
view_eighth_to_ninth_marks();
}
else
if (tabControl1.SelectedTab == tabPage1)
{ view_load_lkg_to_seventh();
}
else if(tabControl1.SelectedTab == tabPage3)
{
view_load_tenthclass_marks();
}
}