Wednesday, 23 April 2014

How to populate the Gridview in page in Asp.Net

 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)
    {
       SqlConnection con = new Sqlconnection("User id =sa; pwd="123" server="ServerName" DataBase="DataBaseName");
          SqlDataAdapter da = new SqlDataAdapter("Select * form employee" ,con);
           DataSet ds = new DataSet();
      da.Fill(ds,"Employee");
Gridview1.DataSource =ds;
Gridview1.DataBind();

    }
}

No comments:

Post a Comment