DATAVIEW CODE LISTING
DataTable customers = new DataTable("Customers");
string cmdStr = ConfigurationManager.ConnectionStrings["nwind"].ConnectionString;
using (SqlConnection connection = new SqlConnection(cmdStr))
{
SqlCommand selectAllCustomers = connection.CreateCommand();
selectAllCustomers.CommandText = "Select * from [Customers]";
connection.Open();
customers.Load(selectAllCustomers.ExecuteReader(CommandBehavior.CloseConnection));
}
DataView dv = new DataView(customers, "Region= 'SP' and Country = 'Brazil'", "ContactName", DataViewRowState.CurrentRows);
GridView1.DataSource = dv;
GridView1.DataBind();
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment