locked
Filtering data from drop down list into gridview RRS feed

  • Question

  • Hi,

     

    what I have: DDL with: All Items / Hire / Rent.

    When selecting "Hire" , all items with hire are shown in grid, same for Rent.

    But when selecting All Items, nothing is shown at all.

    I use VB.NET (not C++). How can I solve that problem.

     

    Thanks in advance

     

    Nopel

    Friday, April 29, 2011 8:38 AM

Answers

  • Hi Nopel,

    Welcome to the MSDN Forum.

    According to your code, it seems that the typeHandelen means the hire type(hire/rent). I assume when you select hire, you pass "hire" to the paramenter, and select rent, you pass "rent". and when select all items, you have passed nothing.

    If so, I have a suggestion for your reference:

    Change the "where" statement to this "WHERE (Woningen.TypeHandelen = @TypeHandelen1) or (Woningen.TypeHandelen = @TypeHandelen2)", when selelct hire, set TypeHandelen1 and TypeHandelen2 = "hire" and the same with rent. when select all, set one of them to "hire", and the other to "rent", and then it will work.

    If not, please tell me more about you filter the data.

    I hope this will be helpful.

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 4, 2011 9:59 AM
    Moderator

All replies

  • How are you filtering items ? Post that part of your code. Are you using BindingSource ? You are able to filter data over Hire/Rent but its not working with All. Is that your problem ?
    Thanks

    Social lounge for MSDN forum users :-)
    Living on Earth may be expensive, but did you know that it includes a free trip around the sun? Isn't that worth it?
    Friday, April 29, 2011 8:47 AM
  •  

    SELECT Klanten.KlantNaam, Woningen.TypeWoning, Woningen.TypeHandelen, Woningen.Prijs

    FROM Klanten INNER JOIN Woningen ON Klanten.id = Woningen.KlantNaam

    WHERE (Woningen.TypeHandelen = @TypeHandelen) 

     

    When clicking the DDL, I get Rent / Hire or All items

     

    Thanks

    maybe fwd all the code ?

     

    Friday, April 29, 2011 8:59 AM
  • Hi Nopel,

    Welcome to the MSDN Forum.

    According to your code, it seems that the typeHandelen means the hire type(hire/rent). I assume when you select hire, you pass "hire" to the paramenter, and select rent, you pass "rent". and when select all items, you have passed nothing.

    If so, I have a suggestion for your reference:

    Change the "where" statement to this "WHERE (Woningen.TypeHandelen = @TypeHandelen1) or (Woningen.TypeHandelen = @TypeHandelen2)", when selelct hire, set TypeHandelen1 and TypeHandelen2 = "hire" and the same with rent. when select all, set one of them to "hire", and the other to "rent", and then it will work.

    If not, please tell me more about you filter the data.

    I hope this will be helpful.

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 4, 2011 9:59 AM
    Moderator