473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Adding textboxes for filtering in DataGrid header

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
Nov 17 '05 #1
0 942

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brian Greiwe | last post by:
I posted this in the datagrid forum but got no bites, so I thought I'd post it here as well for some help.... I've created a datagrid with 1 edititemtemplate column. When the user clicks...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
10
by: milk-jam | last post by:
I'm trying to set my datagridview so that the first row will be left blank and to use it as a filtering filed for the datagridview. Until now I was using 2 datagridview the upper one with a header...
0
by: Sam Vanderstraeten | last post by:
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...
0
by: Hai Nguyen | last post by:
Below is my code, would anybody please figure out why it did not display any thing. The database did not anything in there yet, what it does is the header field. It just shows me the headers only,...
3
by: AMD Desktop | last post by:
Hi, I need to add a header to a datagrid. This is the code I am trying to use: Dim dgStaffingReport As New DataGrid Dim dgitem As New DataGridItem(0, 0, ListItemType.Header) Dim mycell...
2
by: saleek | last post by:
I was wondering if there is a way I can add an extra header to a datagrid? I found this solution on the internet - but it seems quite old and didn't work for me. ...
2
by: dbuchanan | last post by:
Where is the logic error that causes the attached code to adds two rows instead on one to the datagrid? The code correctly update the datasource with one row, but the datagrid gets two new rows....
12
by: JMO | last post by:
I can import a csv file with no problem. I can also add columns to the datagrid upon import. I want to be able to start importing at the 3rd row. This will pick up the headers necessary for the...
0
by: Aishwarya | last post by:
Hello, I want to add a filter to an ultrawingrid such that the first column header displays a textbox in which the user can type the text and the filtering will occur based on the text...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.