Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. set dropdownbox value which affect on other dropdown

set dropdownbox value which affect on other dropdown

Scheduled Pinned Locked Moved ASP.NET
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KIDYA
    wrote on last edited by
    #1

    Hello experts, I want to do is,i have 2 dropdownboxes having names like Country and states ,when i select country then state dropdown box must give respective country's states.Give me way or logic to do this.....

    G D N A 4 Replies Last reply
    0
    • K KIDYA

      Hello experts, I want to do is,i have 2 dropdownboxes having names like Country and states ,when i select country then state dropdown box must give respective country's states.Give me way or logic to do this.....

      G Offline
      G Offline
      Gamzun
      wrote on last edited by
      #2

      Why don't you try little bit harder, I know you can do it :) it's easy

      K 1 Reply Last reply
      0
      • K KIDYA

        Hello experts, I want to do is,i have 2 dropdownboxes having names like Country and states ,when i select country then state dropdown box must give respective country's states.Give me way or logic to do this.....

        D Offline
        D Offline
        deepseeindeepsy
        wrote on last edited by
        #3

        Hi Kemya, You can do this using design time & coding. Which u want to prefer...? :) Its deepak. So..Whats Your Rashi?

        K 1 Reply Last reply
        0
        • D deepseeindeepsy

          Hi Kemya, You can do this using design time & coding. Which u want to prefer...? :) Its deepak. So..Whats Your Rashi?

          K Offline
          K Offline
          KIDYA
          wrote on last edited by
          #4

          Hi Deepak, I done my design work but how will do this by coding,Do uhave any idia? For this i have to make table which contain field like country and state? suggest me proper way!!

          D 1 Reply Last reply
          0
          • G Gamzun

            Why don't you try little bit harder, I know you can do it :) it's easy

            K Offline
            K Offline
            KIDYA
            wrote on last edited by
            #5

            Hello sir!! I got little bit idea , i dont knw its true or wrong? its like i can use onchange event of dropdownbox and sql query.....for sql query i required table having fields country and states... Is it right way?

            G 1 Reply Last reply
            0
            • K KIDYA

              Hi Deepak, I done my design work but how will do this by coding,Do uhave any idia? For this i have to make table which contain field like country and state? suggest me proper way!!

              D Offline
              D Offline
              deepseeindeepsy
              wrote on last edited by
              #6

              Hi kemu... Just give ur email id. Or koin me on G-talk. I will give u straight forward code for it. OK Sir... :)

              K 1 Reply Last reply
              0
              • K KIDYA

                Hello sir!! I got little bit idea , i dont knw its true or wrong? its like i can use onchange event of dropdownbox and sql query.....for sql query i required table having fields country and states... Is it right way?

                G Offline
                G Offline
                Gamzun
                wrote on last edited by
                #7

                Yes absolutely.

                1 Reply Last reply
                0
                • D deepseeindeepsy

                  Hi kemu... Just give ur email id. Or koin me on G-talk. I will give u straight forward code for it. OK Sir... :)

                  K Offline
                  K Offline
                  KIDYA
                  wrote on last edited by
                  #8

                  smartkidya@rediffmail.com Thanx!!

                  D 1 Reply Last reply
                  0
                  • K KIDYA

                    smartkidya@rediffmail.com Thanx!!

                    D Offline
                    D Offline
                    deepseeindeepsy
                    wrote on last edited by
                    #9

                    Sent.. :laugh:

                    1 Reply Last reply
                    0
                    • K KIDYA

                      Hello experts, I want to do is,i have 2 dropdownboxes having names like Country and states ,when i select country then state dropdown box must give respective country's states.Give me way or logic to do this.....

                      N Offline
                      N Offline
                      Nishant Singh
                      wrote on last edited by
                      #10

                      Simplest option would be use UpdatePanel put both dropDowns in Update panel , and just write the normal code (ie:- Server side code on Selected Index Change Event of Country DropDown)

                      1 Reply Last reply
                      0
                      • K KIDYA

                        Hello experts, I want to do is,i have 2 dropdownboxes having names like Country and states ,when i select country then state dropdown box must give respective country's states.Give me way or logic to do this.....

                        A Offline
                        A Offline
                        April Fans
                        wrote on last edited by
                        #11

                        namespace WebApplicationDlh { using System; using System.Data; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using Db; /// <summary> /// Area /// </summary> public class Area : System.Web.UI.UserControl { protected System.Web.UI.WebControls.DropDownList ddlProvince; protected System.Web.UI.WebControls.DropDownList ddlCity; public string strProvince { get { return ddlProvince.SelectedItem.Value; } set { ddlProvince.SelectedItem.Value = value; } } public string strCity { get { return ddlCity.SelectedItem.Value; } set { ddlCity.SelectedItem.Value = value; } } private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { ddlProvinceBind(); ddlCity.Items.Insert(0,"-City to choose-"); } } private void ddlProvinceBind() { Db.Area myArea = new Db.Area(); SqlDataReader dr = myArea.GetAllProvince(); if(dr.Read()) { ddlProvince.DataSource = dr; ddlProvince.DataTextField = "Province"; ddlProvince.DataValueField = "Province"; ddlProvince.DataBind(); ddlProvince.Items.Insert(0,"-Province to choose-"); } } #region Web override protected void OnInit(EventArgs e) { // // CODEGEN: // InitializeComponent(); base.OnInit(e); } /// <summary> /// /// /// </summary> private void InitializeComponent() { this.ddlProvince.SelectedIndexChanged += new System.EventHandler(this.ddlProvince_SelectedIndexChanged); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void ddlProvince_SelectedIndexChanged(object sender, System.EventArgs e) { if(ddlProvince.SelectedItem.Value == "-Province to choose-") { ddlCity.Items.Clear(); ddlCity.Items.Insert(ddlProvince.SelectedIndex,"-City to choose-"); } else { Db.Area myArea = new Db.Area(); SqlDataReader dr = myArea.GetAllCityWhereProvince(ddlProvince.SelectedItem.Value); if(dr.Read()) { ddlCity.DataSource = dr; ddlCity.DataTextField = "City"; ddlCity.DataValueField = "ID"; ddlCity.DataBind(); } } } } } =============================================================〉 using System; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace Db { /// <summary> /// Area /// </summary> public class Area:Base { public Area() { // // TODO: // } public SqlDataReader GetAllProvince() {

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups