binding datasource to dropdownlist control

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default binding datasource to dropdownlist control

    I am being sent an ArrayList of ListItems.

    I can bind to a dropdownlist control using:

    oDropDownList.DataSource = oArrayList

    This works but when the dropdownlist is rendered both the select box value
    and the text are the same (The ListItem.Text), How do I get the
    ListItem.Text to render as the text and the ListItem.Value to be the html
    select option 'value'?

    Thank You,
    Stan


    DesignerX Guest

  2. Similar Questions and Discussions

    1. Binding an array to a DropDownList
      Hi all, I'd like to bind an array to a DropDownList and use the array index as the DataValueField. Is this possible? Thanks, Paul
    2. How to get DataSource for a DropDownList in a Dynamic DataGrid?
      Howdy! I am in the midsts of converting some DataGrids which were previously built in HTML into dynamicly added DataGrids which will be called...
    3. How to gat DataSource for a DropDownList in a Dynamic DataGrid?
      Howdy! I am in the midsts of converting some DataGrids which were previously built in HTML into dynamicly added DataGrids which will be called...
    4. Binding a DropDownList in a DataGrid
      none of these links to INDIA work... "Saravana" <saravank@sct.co.in> wrote in message news:O0#0lqDRDHA.3796@tk2msftngp13.phx.gbl......
    5. Error Binding DropDownList on EditItem Command of DataGrid Control
      I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a...
  3. #2

    Default Re: binding datasource to dropdownlist control

    Use DataTextField and DataValueField properties of dropdownlist to assign
    text and value for dropdownlist.

    --
    Saravana
    Microsoft India Community Star,
    MCAD,SE,SD,DBA.


    "DesignerX" <designerx2@yahoo.com> wrote in message
    news:fL-dnQd3Gd_n_oGiRTvUog@giganews.com...
    > I am being sent an ArrayList of ListItems.
    >
    > I can bind to a dropdownlist control using:
    >
    > oDropDownList.DataSource = oArrayList
    >
    > This works but when the dropdownlist is rendered both the select box value
    > and the text are the same (The ListItem.Text), How do I get the
    > ListItem.Text to render as the text and the ListItem.Value to be the html
    > select option 'value'?
    >
    > Thank You,
    > Stan
    >
    >

    Saravana Guest

  4. #3

    Default Re: binding datasource to dropdownlist control

    Saravana,

    Thanks for the reply, unfortunately that is my problem... I do not know how
    to use the DataValueField property without looping thru the entire
    ArrayList. With an ArrayList of ListItems, how would I use the
    DataValueField to refer property to refer to a property of the object within
    the array?

    Thanks,
    Stan

    "Saravana" <saravank@sct.co.in> wrote in message
    news:Oey3gNAUDHA.2088@TK2MSFTNGP10.phx.gbl...
    > Use DataTextField and DataValueField properties of dropdownlist to assign
    > text and value for dropdownlist.
    >
    > --
    > Saravana
    > Microsoft India Community Star,
    > MCAD,SE,SD,DBA.
    >
    >
    > "DesignerX" <designerx2@yahoo.com> wrote in message
    > news:fL-dnQd3Gd_n_oGiRTvUog@giganews.com...
    > > I am being sent an ArrayList of ListItems.
    > >
    > > I can bind to a dropdownlist control using:
    > >
    > > oDropDownList.DataSource = oArrayList
    > >
    > > This works but when the dropdownlist is rendered both the select box
    value
    > > and the text are the same (The ListItem.Text), How do I get the
    > > ListItem.Text to render as the text and the ListItem.Value to be the
    html
    > > select option 'value'?
    > >
    > > Thank You,
    > > Stan
    > >
    > >
    >
    >

    DesignerX Guest

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