Step By Step explanation
1. The code will check for connection first, if the connection is closed then it will open connection
2. select category_id,category_name,description from category table
3. fill the dataset with records
4. Then fill gridview with dataset, means all records will displayed in gridview
This code will execute if and only if connection is closed
Recommandation:
if (con.State == ConnectionState.Closed)
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
con.Close();