Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > filtering from multiple dropdownlists

Reply
Thread Tools

filtering from multiple dropdownlists

 
 
viktor9990
Guest
Posts: n/a
 
      04-19-2005
I have several DropDownList Controls (ddlOrder, ddlContact...) where the user
may select multiple values and let the results be displayed in the datagrid.
I know how to filter when chosing from any of these dropdownlists. But don't
know how to filer if the user wants to filter based on selection of some of
these dropdownlists at the same time? Any Help? Thanks.

Here is my Code:

Private sub myFilter()
Dim objConn As SqlConnection
Dim strSql As String

strSql = "SELECT Company, Contact, Title, Phone " _
& "FROM Customers"
objConn = New
SqlConnection(ConfigurationSettings.AppSettings("C onnectionString"))

Dim sdaCust As New SqlDataAdapter(strSql, objConn)
Dim dstCust As New DataSet()

sdaCust.Fill(dstCust, "Customers")
Dim dtbCust As DataTable = dstCust.Tables(0)
Dim dtvCust As New DataView(dtbCust)
'" & ddlOrdr.SelectedItem.Text & "'"

dtvCust.RowFilter = "Company = '" & ddlOrder.SelectedItem.Text & "'"
dtvCust.Sort = "ContactName"
dtgCust.DataSource = dtvCust
dtgCust.DataBind()
End Sub
 
Reply With Quote
 
 
 
 
Elton W
Guest
Posts: n/a
 
      04-19-2005
Hi Viktor

You can use

dtvCust.RowFilter = "Company = '" &
ddlOrder.SelectedItem.Text & "' AND ContactName = '" &
ddlContactSelectedItem.Text & "'"

HTH

Elton Wang
http://www.velocityreviews.com/forums/(E-Mail Removed)


>-----Original Message-----
>I have several DropDownList Controls (ddlOrder,

ddlContact...) where the user
>may select multiple values and let the results be

displayed in the datagrid.
>I know how to filter when chosing from any of these

dropdownlists. But don't
>know how to filer if the user wants to filter based on

selection of some of
>these dropdownlists at the same time? Any Help? Thanks.
>
>Here is my Code:
>
>Private sub myFilter()
> Dim objConn As SqlConnection
> Dim strSql As String
>
> strSql = "SELECT Company, Contact, Title, Phone " _
> & "FROM Customers"
> objConn = New
>SqlConnection(ConfigurationSettings.AppSettings

("ConnectionString"))
>
> Dim sdaCust As New SqlDataAdapter(strSql, objConn)
> Dim dstCust As New DataSet()
>
> sdaCust.Fill(dstCust, "Customers")
> Dim dtbCust As DataTable = dstCust.Tables(0)
> Dim dtvCust As New DataView(dtbCust)
>'" & ddlOrdr.SelectedItem.Text & "'"
>
> dtvCust.RowFilter = "Company = '" &

ddlOrder.SelectedItem.Text & "'"
> dtvCust.Sort = "ContactName"
> dtgCust.DataSource = dtvCust
> dtgCust.DataBind()
> End Sub
>.
>

 
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
Strange problem with SelectedIndex property affecting multiple dropdownlists RSH ASP .Net 3 02-08-2007 07:13 PM
filtering from multiple dropdownlists DevCon7@gmail.com ASP .Net Datagrid Control 1 01-20-2007 11:50 AM
Passing Multiple (Controls) Dropdownlists to Another Page's Textboxes Angel.Net ASP .Net 1 06-15-2005 01:10 PM
reuse SQLDataReader in multiple dropdownlists? Craig Buchanan ASP .Net 4 01-15-2004 10:23 PM
Multiple DropDownLists Darren ASP .Net 1 08-18-2003 06:57 AM



Advertisments