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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mohammed SajidPosted Feb 1, 2006, 10:53 AM
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();
---------------------------------------------------------------------------------------
Mohammed SajidPosted Feb 1, 2006, 10:53 AM
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 SajidPosted Feb 1, 2006, 10:53 AM
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();
---------------------------------------------------------------------------------------