Anyone ASP.NET + C# expert online

Discussion in 'C#' started by shaz_again, Jul 25, 2009.

  1. #1
    Hey buddy, I need help in Visual Studio 2008. I want to linked 3 dropdown lists in ASP.NET & C#. also want to know search function.

    If somebody online then plz let me know.
     
    shaz_again, Jul 25, 2009 IP
  2. shaz_again

    shaz_again Peon

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    please i really need to complete my assignment, guys I need your help
     
    shaz_again, Jul 25, 2009 IP
  3. EmeraldOne

    EmeraldOne Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You will have to be more specific..
    What you mean to link three list box??
    is that for the validation controls?
    If so, look up the Group Validation attribute..

    Isaac,
    http://www.7Live7.com
     
    EmeraldOne, Jul 25, 2009 IP
  4. shaz_again

    shaz_again Peon

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It have to link three dropdown lists (Countries, States and Cities) in the way If i select US in next dropdown list its show only US states same with Cities..

    Thanks for reply :)
     
    shaz_again, Jul 25, 2009 IP
  5. shaz_again

    shaz_again Peon

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    no one know how to do this or no one is willing to guide me :(
     
    shaz_again, Jul 26, 2009 IP
  6. asmaster

    asmaster Peon

    Messages:
    86
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You have to store information about cities/stats in a database, to identify which country they belong to.

    After that make all DropDowns' ActivePostBack to True, create OnCahge event, and connect to the database to change available cities/states.
     
    asmaster, Jul 27, 2009 IP
  7. aspdev

    aspdev Guest

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi shaz_again

    asmaster has the right idea. Basically what you want to do is have 3 datatables for Countries, States and Cities in an SQL datatbase or even just an XML datatable. Then you want to populate the drop down list using all the rows from the Countries datatable. When the user selects a country, you want to set the OnChange event to trigger another datatable query. This time you want it to select all states for a specific country. Here is an example

    Basic data table layout
    Table Name: States
    stateID | Country | State
    0 | United States | Texas
    1 | United States | New York
    2 | Canada | State..
    3 | Singapore | State..
    and so on .....

    Then you can just use a LINQ to SQL query to get a list of States where the country is equal to the selected country, like so:

    //Lets say the user chose United States
    string strCountry = "United States";

    //Get all states where country is equal to the selected country
    List<State> lstStates = db.States.Where(s=> s.Country == strCountry).ToList<State>();

    Then just populate the States drop down using the lstStates List.

    If you want this so happen without the page refreshing, make an ajax request using something like jquery to get the List from a page on your site that returns JSON or XML. (I would suggest JSON)

    http://www.json.org/

    Also, if you are using MVC just have an ActionResult return a JavaScript object made using the JSONSerializer class.

    Hope this helps :)

    aspdev
     
    aspdev, Jul 31, 2009 IP