Introduction:
A DataView provides various views of the data stored in a DataTable. Using a DataView, you can expose the data in a table with different sort orders, and you can filter the data by row state or based on a filter expression. That is we can customize the views of data from a DataTable.
Example:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form> </body> </html>
CS:
SqlConnection con = new SqlConnection("Data Source=.; uid=sa; pwd=wintellect;database=Rohatash;"); string strSQL = "Select * from UserDetail"; SqlDataAdapter dt = new SqlDataAdapter(strSQL, con); DataSet ds = new DataSet(); dt.Fill(ds, "UserDetail"); con.Close(); DataView dv = new DataView(); GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind();
0 comments :
Post a Comment