using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class Gridview : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=SREENI\\SQLEXPRESS;Initial Catalog=TestDB;User ID=sa;Password=sa123");
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack);
{
con.Open();
SqlDataAdapter da= new SqlDataAdapter("Select * from tblEmployees",con);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
GridView1.DataSource=ds.Tables[0];
GridView1.DataBind();
}
}
}
execute this one u will get . .