Using 2 dropdowns and 1 gridview

  • 11 years ago

    I want to use two dropdown lists on the same page but have the data go into one gridview when the user clicks on the dropdown list.  Is this possible?  This is the screen shot that I want to achieve.

     

     

    Dropdownlist1

     

    Dropdownlist2

     

    This is the gridview I want to use

    ID

    First Name

    Last Name

    Address

    Job

             
             
             
             
             
     
  • 11 years ago

    Yes, that's possible. Just reload the grid on the changed event of either of the drop down lists.

    Joe 

  • 11 years ago

    Thanks Joe for your response.  I'm a newbie and don't quite understand.  In the Dropdown1 and dropdown2 selected index change do I reload the grid like this...

     

    if dropdown1.selecteditem = dropdown1.selectedindex then

    gridview1.load  (don't know how to code this)

    end if

  • 11 years ago

    JJ, take a look through this series of articles: http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

    Although it talks about a "datagrid", most of it applies for a "gridview".

    and...

    to answer your question, yes, if you want the grid to load when the selected item in dropdown1 is equal to the selected index of dropdown2.

    However, the syntax would be more like:

    gridview1.DataSource = ???

    gridview1.DataBind()

    If you read through the articles mentioned, you'll soon pick it up. Its fairly strightforward once you have a go.

    Joe 

  • 11 years ago

    Excellent article Joe.  Thanks for your help!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone” - Bjarne Stroustrup