Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Adding textboxes for filtering in DataGrid header

Reply
Thread Tools

Adding textboxes for filtering in DataGrid header

 
 
Sam Vanderstraeten
Guest
Posts: n/a
 
      10-01-2003
Hi All,

- Visual Studio 2002
- VB.NET > ASP.NET

I created a DataGrid on a webform. This datagrid has sorting enabled.
I want to create in the header of each column (that is a sorting-hyperlink)
a textbox. When my user clicks on a sort-hyperlink, I want to sort that
column, but I also want to combine that with a rowfilter. That rowfilter
should be the filtervalue, entered in the textbox of that specific column.
F.e.:

Nr | Name | Age | Eyes |
===================
1 | John | 32 | blue |
-----------------------------
2 | Marco | 22 | brown |
-----------------------------
3 | Barry | 46 | blue |
-----------------------------
4 | Paolo | 19 | blue |

In the grid above, I would like to have a textbox in each columnheader... My
user enters f.e. *o* in the textbox of "Name", I want to attach a rowfilter
to this records. This will return me "John", "Marco" and "Paolo" (all
contain an "o"). When my user clicks on "Age", I want to sort those records
by their age. Now my user want to specify his filter, and wants to filter
those records by the color of their eyes. He enters "blue" in the textbox of
the column "Eyes", clicks on the sort-hyperlink and needs to get "John" and
"Paolo" (wich has an "o" AND has blue eyes).

This is my code to filter:

Private Sub DataGrid1_SortCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
DataGrid1.SortCommand
OleDbDataAdapter1.Fill(DataSet11)
If TextBoxFilter.Text <> "" Then
DataView1.RowFilter = e.SortExpression.ToString & " LIKE '" &
TextBoxFilter.Text & "*'"
End If
DataView1.Sort = e.SortExpression.ToString
DataGrid1.DataSource = DataView1
DataGrid1.DataBind()
End Sub

This code has only one textbox for each column, so I can filter only one
column at a time. Note that I can't create a textbox for each column
manually, because my Grid is generated dynamically at runtime.

Thanks for any suggestion!

Greetings,

Sam



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding textboxes for filtering in DataGrid header Sam Vanderstraeten ASP .Net Datagrid Control 0 10-02-2003 06:57 AM
Adding textboxes for filtering in DataGrid header Sam Vanderstraeten ASP .Net 0 10-02-2003 06:57 AM
Adding textboxes for filtering in DataGrid header Sam Vanderstraeten ASP .Net Building Controls 0 10-02-2003 06:57 AM
Adding textboxes for filtering in DataGrid header Sam Vanderstraeten ASP .Net 0 10-01-2003 01:20 PM
Adding textboxes for filtering in DataGrid header Sam Vanderstraeten ASP .Net Building Controls 0 10-01-2003 01:20 PM



Advertisments