2006-11-08
Asp.Net2.0 DataView
Dim cn As New SqlConnection("Server=localhost;Database=Northwind;UID=sa;PWD=P@ssw0rd;")
Dim da As New SqlDataAdapter("select ProductID, ProductName, UnitPrice from Products", cn)
Dim ds As New DataSet
da.Fill(ds, "Products")
'1,
'Dim dv As New DataView(ds.Tables("Products"))
'2,
Dim dv As DataView = ds.Tables("Products").DefaultView
dv.RowFilter = "UnitPrice>50"
dv.Sort = "UnitPrice"
GridView1.DataSource = dv
GridView1.DataBind()
dv.RowFilter = "UnitPrice<20"
dv.Sort = "UnitPrice desc"
GridView2.DataSource = dv
GridView2.DataBind()
dv.RowFilter = "UnitPrice>=20 and UnitPrice<=50"
GridView3.DataSource = dv
GridView3.DataBind()
Dim da As New SqlDataAdapter("select ProductID, ProductName, UnitPrice from Products", cn)
Dim ds As New DataSet
da.Fill(ds, "Products")
'1,
'Dim dv As New DataView(ds.Tables("Products"))
'2,
Dim dv As DataView = ds.Tables("Products").DefaultView
dv.RowFilter = "UnitPrice>50"
dv.Sort = "UnitPrice"
GridView1.DataSource = dv
GridView1.DataBind()
dv.RowFilter = "UnitPrice<20"
dv.Sort = "UnitPrice desc"
GridView2.DataSource = dv
GridView2.DataBind()
dv.RowFilter = "UnitPrice>=20 and UnitPrice<=50"
GridView3.DataSource = dv
GridView3.DataBind()