Tuesday, January 26, 2010

Bind the data with Gridview, Datalist and Repeater

public void BindData()
{
conn.Close();
cmd = new SqlCommand(“select * from tbl_test”, conn);
cmd.CommandType = CommandType.Text;
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds, “tbl_test”);
conn.Open();
cmd.ExecuteReader();
dgcategory.DataSource = ds;
conn.Close();
try
{
dgcategory.DataBind();
}
catch
{
dgcategory.CurrentPageIndex = 0;
}
}