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. Lost selection from dropdownlist after postback???

Lost selection from dropdownlist after postback???

Scheduled Pinned Locked Moved ASP.NET
sysadminquestion
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.
  • J Offline
    J Offline
    JimFeng
    wrote on last edited by
    #1

    I have 2 dropdownlists on a formview. The list of the second one (ddl_2) is depend on the selected value of the first one (ddl_1). I use a client callback function (GetDDL2List) on event OnChange to retrieve the list for the second one. After I selected for a value from the first one list of the second come out correctly. After I make a selection from the second one and submit (post back) the form, however, the selection of the second one is lost. <asp:DropDownList ID="ddl_1" Runat="server" DataSourceID="ods_1" DataValueField="cde_item" DataTextField="txt_item" OnDataBound="ddl_1_DataBound" onchange="GetDDL2List(this.value, 'ddl'); " /> <asp:ObjectDataSource ID="ods_1" Runat="server" TypeName="Proj1.Test" SelectMethod="GetList1" </asp:ObjectDataSource> <asp:DropDownList ID="ddl_2" Runat="server" DataSourceID="ods_2" DataValueField="cde_tem" DataTextField="txt_item" OnDataBound="ddl_2_DataBound" /> <asp:ObjectDataSource ID="ods_2" Runat="server" TypeName="Proj1.Test" SelectMethod="GetList2" <SelectParameters> <asp:ControlParameter Name="sGroup" ControlID="ddl_1" DefaultValue="-1" Type="string" /> </SelectParameters> </asp:ObjectDataSource>

    C 1 Reply Last reply
    0
    • J JimFeng

      I have 2 dropdownlists on a formview. The list of the second one (ddl_2) is depend on the selected value of the first one (ddl_1). I use a client callback function (GetDDL2List) on event OnChange to retrieve the list for the second one. After I selected for a value from the first one list of the second come out correctly. After I make a selection from the second one and submit (post back) the form, however, the selection of the second one is lost. <asp:DropDownList ID="ddl_1" Runat="server" DataSourceID="ods_1" DataValueField="cde_item" DataTextField="txt_item" OnDataBound="ddl_1_DataBound" onchange="GetDDL2List(this.value, 'ddl'); " /> <asp:ObjectDataSource ID="ods_1" Runat="server" TypeName="Proj1.Test" SelectMethod="GetList1" </asp:ObjectDataSource> <asp:DropDownList ID="ddl_2" Runat="server" DataSourceID="ods_2" DataValueField="cde_tem" DataTextField="txt_item" OnDataBound="ddl_2_DataBound" /> <asp:ObjectDataSource ID="ods_2" Runat="server" TypeName="Proj1.Test" SelectMethod="GetList2" <SelectParameters> <asp:ControlParameter Name="sGroup" ControlID="ddl_1" DefaultValue="-1" Type="string" /> </SelectParameters> </asp:ObjectDataSource>

      C Offline
      C Offline
      ChrisKo 0
      wrote on last edited by
      #2

      Verify that when you bind your DropDownLists that you are only doing it if !Page.IsPostBack

      J 1 Reply Last reply
      0
      • C ChrisKo 0

        Verify that when you bind your DropDownLists that you are only doing it if !Page.IsPostBack

        J Offline
        J Offline
        JimFeng
        wrote on last edited by
        #3

        Thanks for your response. I use two-way databinding and I can not stop the databind.

        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