RE: DataGrid Hide Rows

G

Guest

Two options:

1. Build the criteria into your database select.

2. Set a rowfilter in the full dataset itself, then do the databind.

3. Bind your unfiltered dataset, then trap in the ItemDataBound event of the
grid, e.g. get your row, do your checks, then maybe hide that row (e.g.
e.item.visible=false).

I use one or the other depending on the relative number of rows I expect to
hide, or whether the filter criteria are easy to specify in the sql or are
better-suited to do in the code.

Bill
 
C

Chris

The only way i have been able to hide rows is to build the datagrid on the
fly.. here is a same grid

function bla(byval ds as dataset)
Dim dt As New DataTable
Dim dr2, dr As DataRow
Dim AddColumn As New ButtonColumn
' AddColumn.HeaderText = "Add Item"
AddColumn.ButtonType = ButtonColumnType.PushButton
AddColumn.CommandName = "Edit"
AddColumn.Text = "Edit"
Me.datagrid1.Columns.Add(AddColumn)
AddColumn = New ButtonColumn
' AddColumn.HeaderText = "Add Item"
AddColumn.ButtonType = ButtonColumnType.PushButton
AddColumn.CommandName = "Update"
AddColumn.Text = "Tasks"
Me.datagrid1.Columns.Add(AddColumn)
AddColumn = New ButtonColumn
' AddColumn.HeaderText = "Add Item"
AddColumn.ButtonType = ButtonColumnType.PushButton
AddColumn.CommandName = "Delete"
AddColumn.Text = "Delete"
Me.datagrid1.Columns.Add(AddColumn)
dt.Columns.Add(New DataColumn("Task ID", GetType(Long)))
dt.Columns.Add(New DataColumn("Task", GetType(String)))
dt.Columns.Add(New DataColumn("Hours Worked", GetType(Double)))
dt.Columns.Add(New DataColumn("Budgeted Hours", GetType(Double)))
dt.Columns.Add(New DataColumn("Assigned To", GetType(String)))
For Each dr2 In ds.Tables(0).Rows
dr = dt.NewRow
With dr
..Item(0) = dr2.Item(0)
..Item(1) = dr2.Item(1)
..Item(2) = dr2.Item(6)
..Item(3) = dr2.Item(7)
..Item(4) = dr2.Item(3)
End With
dt.Rows.Add(dr)
Next
Me.datagrid1.DataSource = dt
end function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top