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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. change the default selected value in the asp:DropDown

change the default selected value in the asp:DropDown

Scheduled Pinned Locked Moved ASP.NET
question
3 Posts 3 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.
  • G Offline
    G Offline
    gottimukkala
    wrote on last edited by
    #1

    Hi All, I have a page that calls another with parameters (Eg: page2.aspx?show=pdf&w=100&h=200). My page2 contains textboxes and the drop downlist(with default value set to something else), when I enter the page2 I want to set the parameters to my textboxes and dropdown list. I used ddlEmbedDisplay.SelectedValue = show; but its showing the old default value after this statement, Could any one please tell me, my statement is right or wrong. Any Ideas please!!! Thanks, Aruna.G

    A V 2 Replies Last reply
    0
    • G gottimukkala

      Hi All, I have a page that calls another with parameters (Eg: page2.aspx?show=pdf&w=100&h=200). My page2 contains textboxes and the drop downlist(with default value set to something else), when I enter the page2 I want to set the parameters to my textboxes and dropdown list. I used ddlEmbedDisplay.SelectedValue = show; but its showing the old default value after this statement, Could any one please tell me, my statement is right or wrong. Any Ideas please!!! Thanks, Aruna.G

      A Offline
      A Offline
      Ashish Sehajpal
      wrote on last edited by
      #2

      wrong... mention the querystring collection instead use ddlEmbedDisplay.SelectedValue = request.queryString("show") cheers !

      Ashish Sehajpal

      1 Reply Last reply
      0
      • G gottimukkala

        Hi All, I have a page that calls another with parameters (Eg: page2.aspx?show=pdf&w=100&h=200). My page2 contains textboxes and the drop downlist(with default value set to something else), when I enter the page2 I want to set the parameters to my textboxes and dropdown list. I used ddlEmbedDisplay.SelectedValue = show; but its showing the old default value after this statement, Could any one please tell me, my statement is right or wrong. Any Ideas please!!! Thanks, Aruna.G

        V Offline
        V Offline
        vkrajeesh
        wrote on last edited by
        #3

        hi Aruna, From ur query it seems u want to pass a value from one page to another and set that value as the selected Text of a dropdownlist on page 2 when page 2 loads. right? heres how you can do it.its crude but still. //Code on page 1 param1 = "Good Morning"; param2 = 300; Response.Redirect("default2.aspx?param1=" + param1 + "&param2=" + param2.ToString()); //code on page 2 String param1=""; String param2; param1=request.querystring("param1"); param2=request.querystring("param2").tostring(); DropDownList1.Items.Add(param1); DropDownList1.Items.Add(param2); DropDownList1.SelectedIndex = DropDownList1.Items.Count - 1(when new items are added to a dropdownlist they get appended to the end of the list of items.1 denotes the last item,2 would be the second last item etc.) Hope this helps

        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