How to make a databind from a DataSet With Data Tables and TablesAdapters
How to make a databind from a DataSet With Data Tables and TablesAdapters.
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.
Niradhip ChakrabortyPosted Apr 16, 2008, 4:31 PM
Here I am trying to bind ta data from shippers table to datagrid(DataGrid1)
.NET Classes used :
using System.Data.SqlClient;
using System.Collections;
Code:
public void BindGrid()
{
try {
sqlConn = new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"));
string strSQL = "SELECT ShipperID, CompanyName FROM Shippers ORDER BY CompanyName";
SqlDataAdapter da = new SqlDataAdapter(strSQL, sqlConn);
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
}
catch (SqlException ex) {
Response.Write(ex.ToString());
}
}