public void loaddata() { try { strConnection.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = strConnection; cmd.CommandText = "SELECT * FROM dbo.CategoryMaster "; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); GridCategory.DataSource = ds; GridCategory.DataBind(); cmd.Dispose(); strConnection.Close(); } catch { } finally { strConnection.Close(); } }
private void BindData() { var conString = ConfigurationManager.ConnectionStrings["ProductsCatalogConn"]; SqlConnection con = new SqlConnection(conString.ConnectionString); //SqlCommand cmd = new SqlCommand("SELECT CategoryId, CatName FROM tblCategories", con); SqlCommand cmd = new SqlCommand("dbo.getOrderedCategoryList", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); GridCategory.DataSource = ds; GridCategory.DataBind(); }