hi i need some help regarding to loading data from sql server to datagrid in asp.net page.
so anyone plz... help me...
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Mohammed Sajid15 reputationPosted Feb 1, 2006, 5:53 AM EST
The follwing steps will show you how to connect to sql server db, fetching the records and displaying on to the grid.
Steps:
1. Open a Web application
2. Drag and drop a datagrid and a button on the webform1.aspx
3. Import using System.Data.SqlClient;
3. To button click evet add the follwing code
---------------------------------------------------------------------------------------DataSet ds = new DataSet(); SqlConnection con = new SqlConnection("Data Source=DataSourceName;Initial Catalog=pubs;User Id=sa;Password=sa");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM EMPLOYEE",con);
da.Fill(ds);
DataGrid1.DataSource=ds.Tables[0];
DataGrid1.DataBind();
---------------------------------------------------------------------------------------
Mohammed Sajid15 reputationPosted Feb 1, 2006, 5:53 AM EST
The follwing steps will show you how to connect to sql server db, fetching the records and displaying on to the grid.
Steps:
1. Open a Web application
2. Drag and drop a datagrid and a button on the webform1.aspx
3. Import teh using System.Data.SqlClient;
3. To button click evet add the follwing code
---------------------------------------------------------------------------------------DataSet ds = new DataSet(); SqlConnection con = new SqlConnection("Data Source=DataSourceName;Initial Catalog=pubs;User Id=sa;Password=sa");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM EMPLOYEE",con);
da.Fill(ds);
DataGrid1.DataSource=ds.Tables[0];
DataGrid1.DataBind();
---------------------------------------------------------------------------------------
Mohammed Sajid15 reputationPosted Feb 1, 2006, 5:53 AM EST
The follwing steps will show you how to connect to sql server db, fetching the records and displaying on to the grid.
Steps:
1. Open a Web application
2. Drag and drop a datagrid and a button on the webform1.aspx
3. Import the using System.Data.SqlClient;
3. To button click evet add the follwing code
---------------------------------------------------------------------------------------DataSet ds = new DataSet(); SqlConnection con = new SqlConnection("Data Source=DataSourceName;Initial Catalog=pubs;User Id=sa;Password=sa");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM EMPLOYEE",con);
da.Fill(ds);
DataGrid1.DataSource=ds.Tables[0];
DataGrid1.DataBind();
---------------------------------------------------------------------------------------