All my drop down lists get reset to the first value when I go in to edit a record in the datagrid....

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default All my drop down lists get reset to the first value when I go in to edit a record in the datagrid....

    I've got my datagrid working to the point where I can edit records and even
    pick different values in my dropdownlists, save the record and have that
    data committed to the table. The problem I am having is that when I go into
    edit a record each of my picklist values get reset to the first value in the
    list.


    How can I fix this??

    Josh Behl


    Josh Behl Guest

  2. Similar Questions and Discussions

    1. Drop-down lists in a grid
      :confused; Hopefully some of the experienced CF developers out there can help me, a newcomer to the delights of CF/Dreamweaver app development!...
    2. coldfusion drop down lists
      i am trying to build a page with two drop down lists. one with user ids, pulling the list of ids from form variables. the other lists is projects,...
    3. Datagrid with Drop Down Lists
      In an asp.net page that has a datagrid, how do you change the data for that column to be listed in a listbox with the current value selected?
    4. Linked drop down lists
      Can anyone tell me how I go about making one list in a form only show relevant details depending what the user chooses in the preceeding list box....
    5. 2 drop-down lists
      Micha wrote: PHP runs on the server. You need client-side scripting, probably Javascript. Cross-posted and followups set. -- Jim Dabell
  3. #2

    Default Re: All my drop down lists get reset to the first value when I go in to edit a record in the datagrid....

    "Josh Behl" <jbehl@cableone.net> wrote in message news:<#$za6APnDHA.644@TK2MSFTNGP11.phx.gbl>...
    > I've got my datagrid working to the point where I can edit records and even
    > pick different values in my dropdownlists, save the record and have that
    > data committed to the table. The problem I am having is that when I go into
    > edit a record each of my picklist values get reset to the first value in the
    > list.
    >
    >
    > How can I fix this??
    >
    > Josh Behl
    Hi Josh

    This is possibly happening because you dont have an 'isPostBack'
    condition in your page_load sub. When you push the button to execute,
    the page_load sub is called and your dropdownlists will be populated
    again, using the first value of the list as the 'selected value'. This
    can be fixed by putting the initial page loading code inside the
    following if statement:

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load

    If Not IsPostBack Then
    'Populate dropdownlist
    End If

    End Sub

    Good luck
    cfaul Guest

  4. #3

    Default Re: All my drop down lists get reset to the first value when I go in to edit a record in the datagrid....

    I am currently populating my drop down lists with a collection of values
    which I enter in the html code itself:
    <asp:DropDownList id=ddlFee runat="server" Width="80px"
    DataMember="OptionRequestCRM" DataSource="" DataTextField="Fee"
    DataValueField="OptionID">
    <asp:ListItem Value="1">1</asp:ListItem>
    <asp:ListItem Value="2">2</asp....etc...

    Since I am populating my drop down this way, is there another solution????


    "cfaul" <charlene@rgt.co.za> wrote in message
    news:e6200ba0.0310272235.266a3781@posting.google.c om...
    > "Josh Behl" <jbehl@cableone.net> wrote in message
    news:<#$za6APnDHA.644@TK2MSFTNGP11.phx.gbl>...
    > > I've got my datagrid working to the point where I can edit records and
    even
    > > pick different values in my dropdownlists, save the record and have that
    > > data committed to the table. The problem I am having is that when I go
    into
    > > edit a record each of my picklist values get reset to the first value in
    the
    > > list.
    > >
    > >
    > > How can I fix this??
    > >
    > > Josh Behl
    >
    > Hi Josh
    >
    > This is possibly happening because you dont have an 'isPostBack'
    > condition in your page_load sub. When you push the button to execute,
    > the page_load sub is called and your dropdownlists will be populated
    > again, using the first value of the list as the 'selected value'. This
    > can be fixed by putting the initial page loading code inside the
    > following if statement:
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    >
    > If Not IsPostBack Then
    > 'Populate dropdownlist
    > End If
    >
    > End Sub
    >
    > Good luck

    Josh Behl Guest

  5. #4

    Default Re: All my drop down lists get reset to the first value when I go in to edit a record in the datagrid....

    You can databind the dropdownlist in the code behind file as well.
    As charlene mentioned the data might be getting repopulated on postback.
    You might want to prevent the datagrid that contains the dropdownlist from
    rebinding on postback.

    Hope this helps.
    Imtiaz Hussain

    Imtiaz Hussain Guest

  6. #5

    Default Re: All my drop down lists get reset to the first value when I go in to edit a record

    I had Page.IsPostBack and it didin't work. So pay attention that only code on page loadshould be
    if not IsPostack and data will be saved correctly
    Seni Buljat is offline Junior Member
    Join Date
    Sep 2011
    Posts
    1

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139