I've gathered a bunch of data from Active Directory and placed it into a
datatable ("ADTable"). I now need to sort and filter this table based on
the selection of a drop down list("ddlCategory"). How can I filter the
dataview of this datatable to display those records that match (partially or
fully) the value selected in the drop down list?
I have the following code that doesn't work, and returns zero rows (note
that 'department' is a valid column name as I've tested dvCustom.RowFilter
="department Like Information Management" and it works):
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
'Make a copy of the default dataview of the ADTable so it's refreshed to
original every time button is clicked.
Dim dvCustom As DataView = ADTable.DefaultView
dvCustom.RowFilter = "department LIKE " & "'*" &
ddlCategory.SelectedItem.Text & "*'"
'cn is another column name, is valid and works.
dvCustom.Sort = "cn"
'DGADResults is simply a datagrid that displays the dataview
DGADResults.DataSource = dvCustom
DGADResults.DataBind()
End Sub
Any help would be greatly appreciated!
Thanks in advance,
Jason 1 1677
Thanks alot, that worked alot better than trying to create a custom filter
with wildcards, etc (which I did end up getting to work as well, but
disgarded for this simpler way).
Thanks again.
"vzaffiro" <vz******@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com... Hey jason,
I have done this thru a datatable using the following logic //Create the datatable from the dataset DataTable dt = Common.GetLookupTable(table,webpage);
//Foundrows is an array that will be returned from the select DataRow[] foundRows;
//Create the where clause string whereclause = string.Format("cdstatus = {0} and cdstatus_apr_ord = {1}",cdStatus,currentOrder)
//Fill the array by filtering the data table foundRows = dt.Select(whereclause);
Foundrows now has an array of datarows that you can traverse.
Here are some references: http://www.akadia.com/services/dotnet_filter_sort.html http://www.eggheadcafe.com/articles/20030903.asp
Good Luck!
"Jason" wrote:
I've gathered a bunch of data from Active Directory and placed it into a datatable ("ADTable"). I now need to sort and filter this table based
on the selection of a drop down list("ddlCategory"). How can I filter the dataview of this datatable to display those records that match
(partially or fully) the value selected in the drop down list?
I have the following code that doesn't work, and returns zero rows (note that 'department' is a valid column name as I've tested
dvCustom.RowFilter ="department Like Information Management" and it works):
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
'Make a copy of the default dataview of the ADTable so it's
refreshed to original every time button is clicked.
Dim dvCustom As DataView = ADTable.DefaultView
dvCustom.RowFilter = "department LIKE " & "'*" & ddlCategory.SelectedItem.Text & "*'" 'cn is another column name, is valid and works. dvCustom.Sort = "cn"
'DGADResults is simply a datagrid that displays the dataview
DGADResults.DataSource = dvCustom DGADResults.DataBind() End Sub
Any help would be greatly appreciated!
Thanks in advance,
Jason This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alex Ayzin |
last post by:
Hi,
I have a problem that might be easy to solve(possibly, I've just overlooked
an easy solution). Here we go:
I have a dataset with 2 datatables in it. Now, I need to do the following:
if...
|
by: Patrick |
last post by:
I'm working on a contact management application, and need a hand with one
aspect...
Here's what I want to create:
------------------------------------
A form split into two parts. There is a...
|
by: Ubi |
last post by:
hi
i have a problem with System.Data.DataViewRowState.
i have a ReadOnly datagrid,
a dataView and a dataTable.
i'm using the dataView's filter property to filter the data (firstName =...
|
by: Siegfried Heintze |
last post by:
I'm displaying information on job postings in various cities. For example,
might have a dozen jobs in Atlanta GA and I decide, at run time, that I
don't want to see them. How do I set my DataView...
|
by: John Wildes |
last post by:
Hello
I have a small program that I've created to generate accounting
statements out of our policy managment system.
The first part of the process is selecting the customer to create the...
|
by: |
last post by:
Hello,
Does anyone have an idea on how I can filter the data in the gridview
control that was returned by an sql query?
I have a gridview that works fine when I populate it with data. Now I...
|
by: LDD |
last post by:
Hi Folks
I'm trying to determine a way to handle paging, filtering and sorting in a
datagrid.
If I choose to filter and sort, I'd like to return a subset. If that
resultset has more records...
|
by: Anup Daware |
last post by:
Abstract: I want to filter a dataview with a value where column name
have a SPACE.
Description:-
I bind a dataview to a datagrid,
The query which is fetching the results in Dataset is something...
|
by: Harry Haller |
last post by:
Hello, I want to implement a generic list which will be used to
display 7 columns in a GridView. One should be able to sort, filter
and page each of the 7 columns. Ideally the filter should be...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |