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. Drop down list

Drop down list

Scheduled Pinned Locked Moved Web Development
csharpasp-netwpfwcfquestion
3 Posts 2 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 Offline
    T Offline
    Tauseef A
    wrote on last edited by
    #1

    hi guys i am using asp.net1.1 . i am using dropdownlist,, i have bouned this dropdown with a datasource with data set object, but i want show an empty string on the click event of the clear button, i dont want the data binding to be removed, i just want to show the selected text in the drop down which should be blank string, is there any way ? thanks in advance regards

    hello

    S 1 Reply Last reply
    0
    • T Tauseef A

      hi guys i am using asp.net1.1 . i am using dropdownlist,, i have bouned this dropdown with a datasource with data set object, but i want show an empty string on the click event of the clear button, i dont want the data binding to be removed, i just want to show the selected text in the drop down which should be blank string, is there any way ? thanks in advance regards

      hello

      S Offline
      S Offline
      Sreekumar P P
      wrote on last edited by
      #2

      i would recomend to add a default text to the dropdown after binding. dropdownXYZ.DataSource = something; dropdownXYZ.DataValueField = something; dropdownXYZ.DataTextField = something; dropdownXYZ.DataBind(); dropdownXYZ.Items.Add("Select One"); dropdownXYZ.SelectedIndex = ddlEventIDONX.Items.Count-1; // Assuming that you won't be having any negetive value in real time. dropdownXYZ.SelectedItem.Value = "-1"; --- On Clear Button Click event, change the drowndown to "-1" However, i would recommend this clear button to have javascript function. Why should it make an unnecessary round trip to server and waste time even if that is just seconds. --Javascript --- loop thru the document and find all required controls like text box, dropdowns etc and clear it.... ---- var controls = document.all; if(controls[i].tagName == 'INPUT' || controls[i].tagName == 'SELECT' || controls[i].tagName == 'TEXTAREA' || ... etc) if(controls[i].value.length > 0 ) { //Clearing Text Box if(controls[i].tagName == 'INPUT') controls[i].value = ""; //For DropDows else if(controls[i].tagName == 'SELECT' ) { if(controls[i].value != -1) controls[i].value = -1; } else if(controls[i].tagName == 'TEXTAREA') controls[i].value = ""; ----- etc.. } Sreekumar PP

      T 1 Reply Last reply
      0
      • S Sreekumar P P

        i would recomend to add a default text to the dropdown after binding. dropdownXYZ.DataSource = something; dropdownXYZ.DataValueField = something; dropdownXYZ.DataTextField = something; dropdownXYZ.DataBind(); dropdownXYZ.Items.Add("Select One"); dropdownXYZ.SelectedIndex = ddlEventIDONX.Items.Count-1; // Assuming that you won't be having any negetive value in real time. dropdownXYZ.SelectedItem.Value = "-1"; --- On Clear Button Click event, change the drowndown to "-1" However, i would recommend this clear button to have javascript function. Why should it make an unnecessary round trip to server and waste time even if that is just seconds. --Javascript --- loop thru the document and find all required controls like text box, dropdowns etc and clear it.... ---- var controls = document.all; if(controls[i].tagName == 'INPUT' || controls[i].tagName == 'SELECT' || controls[i].tagName == 'TEXTAREA' || ... etc) if(controls[i].value.length > 0 ) { //Clearing Text Box if(controls[i].tagName == 'INPUT') controls[i].value = ""; //For DropDows else if(controls[i].tagName == 'SELECT' ) { if(controls[i].value != -1) controls[i].value = -1; } else if(controls[i].tagName == 'TEXTAREA') controls[i].value = ""; ----- etc.. } Sreekumar PP

        T Offline
        T Offline
        Tauseef A
        wrote on last edited by
        #3

        Thank you very much it helped me very much Regards

        hello

        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