using System;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindgridview();
}
}
protected void bindgridview()
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Northwind;Integrated Security = True");
con.Open();
SqlCommand cmd = new SqlCommand("Select * from Categories", con);
SqlDataAdapter add = new SqlDataAdapter(cmd);
DataSet da = new DataSet();
add.Fill(da);
GridView1.DataSource = da;
GridView1.DataBind();
}
}