Monday, July 23, 2012

DataView:
A DataView defines a view onto a DataTable object. It is a representation of a data in a DataTable that can include custom filtering and sorting. The Data Views are particularly useful in data binding scenarios.

            //Windows Authentication
            String ConnectionString = "server=localhost; database=AdventureWorks; Integrated Security=True";

            SqlConnection conn = new SqlConnection(ConnectionString);
            conn.Open();

            string qryString = "SELECT TOP 10 * FROM Person.Contact";
            SqlDataAdapter da = new SqlDataAdapter(qryString, conn);

            DataSet ds = new DataSet();
            da.Fill(ds, "Employee");
            DataTable dt = new DataTable();
            dt = ds.Tables[0];
            DataView dv = new DataView(dt);
            dv.RowFilter = "FirstName='Govson'";
            dv.Sort = "contactID ASC";
   
Overview of Grid Controls:

DataRepeter Control:
 This control enables to display set of items from data source with any type of formatting. It can be bind a Repeater control to either a DataSet or a Data Reader. While using Repeater control we are required to supply at least one template.
Repeater Control supports the following templates:
  • Item Template
  • Alternating Item Template
  • Header Template
  • Separator Template
  • Footer Template


No comments:

Post a Comment