|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
multiple Rowfiltering and binding the changes to the datagridHere my code: Sub BindData(ByVal SelectedProduct As String, ByVal SelectedClient As String, ByVal SelectedSupplier As String, ByVal SelectedSalesman As String) Dim DSreporteorden As New DataSet Dim DTreporteorden As New DataTable Dim DAreporteorden As New SqlDataAdapter Dim view As New DataView view = Cache("reporteorden") If view Is Nothing Then ..setting up connection.. ..querying the database and retrieving data.. DAreporteorden.Fill(DSreporteorden) DTreporteorden = DSreporteorden.Tables(0) view = DTreporteorden.DefaultView Cache("reporteorden") = view objConn.Close() End If If SelectedProduct <> "All" Then view.RowFilter = "O_16 = '" & SelectedProduct & "'" End If If SelectedClient <> "All" Then view.RowFilter = "O_7 = '" & SelectedClient & "'" End If If SelectedSupplier <> "All" Then view.RowFilter = "O_6 = '" & SelectedSupplier & "'" End If If SelectedSalesman <> "All" Then view.RowFilter = "O_13 = '" & SelectedSalesman & "'" End If DGreporteorden.DataSource = view DGreporteorden.DataBind() End Sub I would be grateful to receive a hint :-) Regards, Robert Gregory Robert,
I think you can make complex conditions with OR, AND and NOT operators. Also, you always have an option of modifying the select statement according to all filters. Eliyahu "Robert Gregory via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in the user may select multiple values and let the results be displayed in themessage news:4267b5d7827440b98ff5d2ffe62eccac@DotNetMonster.com... > I have the following problem: I have several DropDownList Controls where datagrid. The first filter will always work, but when the second filter is done, the effects of the first filtering are lost. So how do I make a filtering permanent, so that for the next filtering which is done the modified datatable is used? > Here my code: String, ByVal SelectedSupplier As String, ByVal SelectedSalesman As String)> > Sub BindData(ByVal SelectedProduct As String, ByVal SelectedClient As Show quoteHide quote > Dim DSreporteorden As New DataSet > Dim DTreporteorden As New DataTable > Dim DAreporteorden As New SqlDataAdapter > Dim view As New DataView > view = Cache("reporteorden") > If view Is Nothing Then > ..setting up connection.. > ..querying the database and retrieving data.. > DAreporteorden.Fill(DSreporteorden) > DTreporteorden = DSreporteorden.Tables(0) > view = DTreporteorden.DefaultView > Cache("reporteorden") = view > objConn.Close() > End If > If SelectedProduct <> "All" Then > view.RowFilter = "O_16 = '" & SelectedProduct & "'" > End If > If SelectedClient <> "All" Then > view.RowFilter = "O_7 = '" & SelectedClient & "'" > End If > If SelectedSupplier <> "All" Then > view.RowFilter = "O_6 = '" & SelectedSupplier & "'" > End If > If SelectedSalesman <> "All" Then > view.RowFilter = "O_13 = '" & SelectedSalesman & "'" > End If > DGreporteorden.DataSource = view > DGreporteorden.DataBind() > End Sub > > I would be grateful to receive a hint :-) > > Regards, > Robert Gregory > > -- > Message posted via http://www.dotnetmonster.com Thanks for the remarks...BUT: If I use connectors like AND to combine the different rowfilter, I will have to write code for every possible combination. Why? Because the user has the choice to select something or not. 0 or 1 if you like. This corresponds to 2 out of 4 possible combinations. When I finally get my problem solved I want to add another 4 dropdownlist for the user to select. This will get to complicated. That's why I have to process one filter at a time and after each other...??? Any ideas???
THANKS a lot...in the end the idea was good, I tried it with AND and it worked :-)
Here the code, in case anybody wants to see an example. Dim Filtro As String Filtro = " " If SelectedProduct <> "Todos" Then Filtro = "O_16 = '" & SelectedProduct & "'" End If If SelectedClient <> "Todos" Then If Filtro <> " " Then Filtro = Filtro & " AND O_7 = '" & SelectedClient & "'" Else Filtro = "O_7 = '" & SelectedClient & "'" End If End If If SelectedSupplier <> "Todos" Then If Filtro <> " " Then Filtro = Filtro & " AND O_6 = '" & SelectedSupplier & "'" Else Filtro = "O_6 = '" & SelectedSupplier & "'" End If End If If SelectedSalesman <> "Todos" Then If Filtro <> " " Then Filtro = Filtro & " AND O_13 = '" & SelectedSalesman & "'" Else Filtro = "O_13 = '" & SelectedSalesman & "'" End If End If If SelectedOrden <> "" Then If Filtro <> " " Then Filtro = Filtro & " AND O_3 = '" & SelectedOrden & "'" Else Filtro = "O_3 = '" & SelectedOrden & "'" End If End If If SelectedOrden_C <> "" Then If Filtro <> " " Then Filtro = Filtro & " AND O_4 = '" & SelectedOrden_C & "'" Else Filtro = "O_4 = '" & SelectedOrden_C & "'" End If End If view.RowFilter = Filtro Regards, Robert Gregory
Casting a grid
Refresh problem How to Make Calculator in ASP and Cold fusion Paging for DataList Control auto postback(urgent!) selecting a DataGridRow wipes out the selected row's text Suggestion Can You Change Colors on GridLines? error in getting textbox value in EditCommand Nested datagrids or repeaters...etc. |
|||||||||||||||||||||||