How to display record in gridview using pageload event in vb.net?
How to display record in gridview using pageload event in vb.net ?
i wanna use two SqlDatasource1 and sqldatasource 2 to display record in single gridview1
SqlDatasource1 will display all records from t开发者_运维技巧abel where as SqlDatasource will be used to display particuar record search in table 1 but how to do this ?
I'm not sure why you want to display all records from a table besides the records that belong to a particaúlar filter on that table. How do you want do make clear what is the filtered and what the unfiltered part?
You could use UNION ALL to combine two resultsets together. You could also add a column that contains a boolean if it belongs to the filtered set. On this way you would be able to add different CssClasses to the rows according to this column value from RowDataBound in Codebehind.
For example:
SELECT Foo.*,0 AS IsFiltered FROM Foo
UNION ALL
SELECT Foo.*,1 AS IsFiltered FROM Foo
where Name like 's%
You only need one SQL-Datasource on this way.
To set a different CssClass for the filtered records:
Private Sub GridRowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim row As DataRowView = DirectCast(e.Row.DataItem, DataRowView)
Dim isFiltered As Boolean = CType(row("IsFiltered"), Boolean)
If isFiltered Then e.Row.CssClass = "FilteredRecords"
End If
End Sub
'
精彩评论