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. Dropdown

Dropdown

Scheduled Pinned Locked Moved ASP.NET
help
11 Posts 4 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.
  • T Tripat Bala Singh

    i have a dropdown in my page this is use for State and i have bound state list in dropdown but when submit form then error msg show "'drpCrntState' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value" tripat bala singh

    T Offline
    T Offline
    thatraja
    wrote on last edited by
    #2

    Show your code

    thatraja

    FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
    HTML Marquee & its alternatives

    Nobody remains a virgin, Life screws everyone :sigh:

    T 1 Reply Last reply
    0
    • T Tripat Bala Singh

      i have a dropdown in my page this is use for State and i have bound state list in dropdown but when submit form then error msg show "'drpCrntState' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value" tripat bala singh

      T Offline
      T Offline
      thatraja
      wrote on last edited by
      #3

      Based on your question & this discussion[^], you have used SelectedValue property instead of DataValueField.

      thatraja

      FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
      HTML Marquee & its alternatives

      Nobody remains a virgin, Life screws everyone :sigh:

      1 Reply Last reply
      0
      • T thatraja

        Show your code

        thatraja

        FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
        HTML Marquee & its alternatives

        Nobody remains a virgin, Life screws everyone :sigh:

        T Offline
        T Offline
        Tripat Bala Singh
        wrote on last edited by
        #4

        protected void btnSave_Click(object sender, EventArgs e) { try { if (btnSave.Text == "Save") { BOStudentDetails ObjStudent = new BOStudentDetails(); ObjStudent.SchoolID = Convert.ToInt32(drpSchool.SelectedValue); ObjStudent.ClassID = Convert.ToInt32(drpClass.SelectedValue); ObjStudent.StudentName = txtStudentFname.Text+ ' ' + txtStudentMname.Text + ' ' + txtStudentLname.Text; //ObjStudent.StudentPhoto = "fsdfs"; ObjStudent.StudentDob = txtdob.Text; ObjStudent.StudentAddmissionDate = txtAdmissionDate.Text; ObjStudent.StudentFthName = txtFthName.Text; ObjStudent.StudentMthName = txtMthName.Text; ObjStudent.StudentCategory = Convert.ToString(drpCategory.SelectedItem); ObjStudent.StudentGender = Convert.ToString(drpGender.SelectedItem); ObjStudent.StudentMobile1 = txtMobile1.Text; ObjStudent.StudentMobile2 = txtMobile2.Text; ObjStudent.StudentLandline = txtLandlinePhon.Text; ObjStudent.StudentDiscription = txtDiscription.Text; ObjStudent.StudentPrmAdd = txtPrmAdd.Text; ObjStudent.StudentPrmState =Convert.ToString(drpPrmState.SelectedItem); ObjStudent.StudentPrmCity = Convert.ToString(drpPrmCity.SelectedItem); ObjStudent.StudentPrmLocation = Convert.ToString(drpPrmLocation.SelectedItem); ObjStudent.StudentPrmPin = txtPrmPin.Text; ObjStudent.StudentCrntAdd = txtCrntAdd.Text; ObjStudent.StudentCrntState = Convert.ToString(drpCrntState.SelectedItem); ObjStudent.StudentCrntCity = Convert.ToString(drpCrntCity.SelectedItem); ObjStudent.StudentCrntLocation = Convert.ToString(drpCrntLocation.SelectedItem); ObjStudent.StudentCrntPin = txtCrntPin.Text; if (flupldStdPhoto.HasFile) { string StudentExtension = Path.GetExtension(flupldStdPhoto.FileName); if (!StudentExtension.ToLower().Equals(".gif") && !StudentExtension.ToLower().Equals(".jpg") && !StudentExtension.ToLower().Eq

        T 1 Reply Last reply
        0
        • T Tripat Bala Singh

          protected void btnSave_Click(object sender, EventArgs e) { try { if (btnSave.Text == "Save") { BOStudentDetails ObjStudent = new BOStudentDetails(); ObjStudent.SchoolID = Convert.ToInt32(drpSchool.SelectedValue); ObjStudent.ClassID = Convert.ToInt32(drpClass.SelectedValue); ObjStudent.StudentName = txtStudentFname.Text+ ' ' + txtStudentMname.Text + ' ' + txtStudentLname.Text; //ObjStudent.StudentPhoto = "fsdfs"; ObjStudent.StudentDob = txtdob.Text; ObjStudent.StudentAddmissionDate = txtAdmissionDate.Text; ObjStudent.StudentFthName = txtFthName.Text; ObjStudent.StudentMthName = txtMthName.Text; ObjStudent.StudentCategory = Convert.ToString(drpCategory.SelectedItem); ObjStudent.StudentGender = Convert.ToString(drpGender.SelectedItem); ObjStudent.StudentMobile1 = txtMobile1.Text; ObjStudent.StudentMobile2 = txtMobile2.Text; ObjStudent.StudentLandline = txtLandlinePhon.Text; ObjStudent.StudentDiscription = txtDiscription.Text; ObjStudent.StudentPrmAdd = txtPrmAdd.Text; ObjStudent.StudentPrmState =Convert.ToString(drpPrmState.SelectedItem); ObjStudent.StudentPrmCity = Convert.ToString(drpPrmCity.SelectedItem); ObjStudent.StudentPrmLocation = Convert.ToString(drpPrmLocation.SelectedItem); ObjStudent.StudentPrmPin = txtPrmPin.Text; ObjStudent.StudentCrntAdd = txtCrntAdd.Text; ObjStudent.StudentCrntState = Convert.ToString(drpCrntState.SelectedItem); ObjStudent.StudentCrntCity = Convert.ToString(drpCrntCity.SelectedItem); ObjStudent.StudentCrntLocation = Convert.ToString(drpCrntLocation.SelectedItem); ObjStudent.StudentCrntPin = txtCrntPin.Text; if (flupldStdPhoto.HasFile) { string StudentExtension = Path.GetExtension(flupldStdPhoto.FileName); if (!StudentExtension.ToLower().Equals(".gif") && !StudentExtension.ToLower().Equals(".jpg") && !StudentExtension.ToLower().Eq

          T Offline
          T Offline
          thatraja
          wrote on last edited by
          #5

          Share the Databind code for drpCrntState.

          thatraja

          FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
          HTML Marquee & its alternatives

          Nobody remains a virgin, Life screws everyone :sigh:

          T 1 Reply Last reply
          0
          • T Tripat Bala Singh

            i have a dropdown in my page this is use for State and i have bound state list in dropdown but when submit form then error msg show "'drpCrntState' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value" tripat bala singh

            A Offline
            A Offline
            Ajay_Saini
            wrote on last edited by
            #6

            This error occurred when your dropdown is already filled and if you try to assign (selects) that value which was selected previously. so can you provide your code?

            T 1 Reply Last reply
            0
            • T thatraja

              Share the Databind code for drpCrntState.

              thatraja

              FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
              HTML Marquee & its alternatives

              Nobody remains a virgin, Life screws everyone :sigh:

              T Offline
              T Offline
              Tripat Bala Singh
              wrote on last edited by
              #7

              public void BindCStateDrp() { var stateList = balStateObj.GetState(0); drpCrntState.DataSource = stateList; drpCrntState.DataTextField = "StateName"; drpCrntState.DataValueField = "StateID"; drpCrntState.DataBind(); drpCrntState.Items.Insert(0, new ListItem("--Select State--", "-1")); } DAL ----------------- public List GetStates(int stateID) { List lstState = new List(); try { SqlParameter[] paramList = { new SqlParameter("@State_Id" , stateID) }; SqlDataReader reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "State_Select_Sp", paramList); while (reader.Read()) { BOState state = new BOState(); state.StateID = (Int32)reader[0]; state.StateName = (String)reader[1]; state.StateStatus = (bool)reader[2]; lstState.Add(state); } } catch { } return lstState; }

              1 Reply Last reply
              0
              • T Tripat Bala Singh

                i have a dropdown in my page this is use for State and i have bound state list in dropdown but when submit form then error msg show "'drpCrntState' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value" tripat bala singh

                A Offline
                A Offline
                anil pathak
                wrote on last edited by
                #8

                Hi Friend, put you code inside on IsPostBack ==false like below code and put the DataTextField and DataValueField properly like this. this code should be in Page_Load events. if (!IsPostBack) { SqlConnection con = new SqlConnection("your connection string here"); SqlDataAdapter da = new SqlDataAdapter("Select StateId,StateName From StateMaster", con); con.Open(); DataSet ds = new DataSet(); da.Fill(ds); DropDownList1.DataSource = ds; DropDownList1.DataTextField = "StateName"; // your dispaly field in dropdownlist DropDownList1.DataValueField = "StateId"; // your value field which you will stare in database DropDownList1.DataBind(); con.Close(); }

                Anil Pathak worked on technologies like C#, VB.net, ASP.net, Web Service, WCF, WPF, Silver Light, MVC 3.0, Jquery, Sql Server.

                T 1 Reply Last reply
                0
                • A anil pathak

                  Hi Friend, put you code inside on IsPostBack ==false like below code and put the DataTextField and DataValueField properly like this. this code should be in Page_Load events. if (!IsPostBack) { SqlConnection con = new SqlConnection("your connection string here"); SqlDataAdapter da = new SqlDataAdapter("Select StateId,StateName From StateMaster", con); con.Open(); DataSet ds = new DataSet(); da.Fill(ds); DropDownList1.DataSource = ds; DropDownList1.DataTextField = "StateName"; // your dispaly field in dropdownlist DropDownList1.DataValueField = "StateId"; // your value field which you will stare in database DropDownList1.DataBind(); con.Close(); }

                  Anil Pathak worked on technologies like C#, VB.net, ASP.net, Web Service, WCF, WPF, Silver Light, MVC 3.0, Jquery, Sql Server.

                  T Offline
                  T Offline
                  Tripat Bala Singh
                  wrote on last edited by
                  #9

                  thank you anil sir i have solve my porblem...with your suport... tripat bala singh

                  1 Reply Last reply
                  0
                  • A Ajay_Saini

                    This error occurred when your dropdown is already filled and if you try to assign (selects) that value which was selected previously. so can you provide your code?

                    T Offline
                    T Offline
                    Tripat Bala Singh
                    wrote on last edited by
                    #10

                    thank you ajay sir i have solve my porblem...with your suport... tripat bala singh

                    A 1 Reply Last reply
                    0
                    • T Tripat Bala Singh

                      thank you ajay sir i have solve my porblem...with your suport... tripat bala singh

                      A Offline
                      A Offline
                      Ajay_Saini
                      wrote on last edited by
                      #11

                      welcome dear!!! keep it up... :)

                      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