asp:DropDownList and databinding

Discussion in 'ASP .Net' started by Mark, Sep 4, 2005.

  1. Mark

    Mark Guest

    Hi, I have a DataList which I populate with databound templates.

    In one of the template I have a dropdown list which is bound to a database
    field consisting of comma-seperated values.
    What I would like to be able to do is split the values and for each value
    generate a new listitem.

    e.g. the string in the database is stored as 127.60,1263.78,8872.76

    When the datalist is bound I want the associated dropdownlist in each row to
    automatically consist of the following

    I would like this information to be placed into
    <asp:ListItem Value="127.60">127.60</asp:ListItem>
    <asp:ListItem Value="1263.78">1263.78</asp:ListItem>
    <asp:ListItem Value="8872.76">8872.76</asp:ListItem>

    TIA
    Cheers
    Mark
    Mark, Sep 4, 2005
    #1
    1. Advertising

  2. Mark,

    does this help you:

    Dim myString As System.String
    myString = "127.60,1263.78,8872.76"

    Dim myStrings() As System.String
    myStrings = myString.Split(",")

    myDataList.DataSource = myStrings

    Regards

    Daniel Walzenbach


    "Mark" <> schrieb im Newsbeitrag
    news:...
    > Hi, I have a DataList which I populate with databound templates.
    >
    > In one of the template I have a dropdown list which is bound to a database
    > field consisting of comma-seperated values.
    > What I would like to be able to do is split the values and for each value
    > generate a new listitem.
    >
    > e.g. the string in the database is stored as 127.60,1263.78,8872.76
    >
    > When the datalist is bound I want the associated dropdownlist in each row
    > to
    > automatically consist of the following
    >
    > I would like this information to be placed into
    > <asp:ListItem Value="127.60">127.60</asp:ListItem>
    > <asp:ListItem Value="1263.78">1263.78</asp:ListItem>
    > <asp:ListItem Value="8872.76">8872.76</asp:ListItem>
    >
    > TIA
    > Cheers
    > Mark
    >
    >
    >
    >
    Daniel Walzenbach, Sep 4, 2005
    #2
    1. Advertising

  3. Mark

    Mark Guest

    Hi Daniel, great, that's it :)
    Thanks
    Mark
    "Daniel Walzenbach" <> wrote in message
    news:...
    > Mark,
    >
    > does this help you:
    >
    > Dim myString As System.String
    > myString = "127.60,1263.78,8872.76"
    >
    > Dim myStrings() As System.String
    > myStrings = myString.Split(",")
    >
    > myDataList.DataSource = myStrings
    >
    > Regards
    >
    > Daniel Walzenbach
    >
    >
    > "Mark" <> schrieb im Newsbeitrag
    > news:...
    > > Hi, I have a DataList which I populate with databound templates.
    > >
    > > In one of the template I have a dropdown list which is bound to a

    database
    > > field consisting of comma-seperated values.
    > > What I would like to be able to do is split the values and for each

    value
    > > generate a new listitem.
    > >
    > > e.g. the string in the database is stored as 127.60,1263.78,8872.76
    > >
    > > When the datalist is bound I want the associated dropdownlist in each

    row
    > > to
    > > automatically consist of the following
    > >
    > > I would like this information to be placed into
    > > <asp:ListItem Value="127.60">127.60</asp:ListItem>
    > > <asp:ListItem Value="1263.78">1263.78</asp:ListItem>
    > > <asp:ListItem Value="8872.76">8872.76</asp:ListItem>
    > >
    > > TIA
    > > Cheers
    > > Mark
    > >
    > >
    > >
    > >

    >
    >
    Mark, Sep 5, 2005
    #3
  4. Sweet :)

    Have fun!

    Daniel Walzenbach

    "Mark" <> schrieb im Newsbeitrag
    news:...
    > Hi Daniel, great, that's it :)
    > Thanks
    > Mark
    > "Daniel Walzenbach" <> wrote in message
    > news:...
    >> Mark,
    >>
    >> does this help you:
    >>
    >> Dim myString As System.String
    >> myString = "127.60,1263.78,8872.76"
    >>
    >> Dim myStrings() As System.String
    >> myStrings = myString.Split(",")
    >>
    >> myDataList.DataSource = myStrings
    >>
    >> Regards
    >>
    >> Daniel Walzenbach
    >>
    >>
    >> "Mark" <> schrieb im Newsbeitrag
    >> news:...
    >> > Hi, I have a DataList which I populate with databound templates.
    >> >
    >> > In one of the template I have a dropdown list which is bound to a

    > database
    >> > field consisting of comma-seperated values.
    >> > What I would like to be able to do is split the values and for each

    > value
    >> > generate a new listitem.
    >> >
    >> > e.g. the string in the database is stored as 127.60,1263.78,8872.76
    >> >
    >> > When the datalist is bound I want the associated dropdownlist in each

    > row
    >> > to
    >> > automatically consist of the following
    >> >
    >> > I would like this information to be placed into
    >> > <asp:ListItem Value="127.60">127.60</asp:ListItem>
    >> > <asp:ListItem Value="1263.78">1263.78</asp:ListItem>
    >> > <asp:ListItem Value="8872.76">8872.76</asp:ListItem>
    >> >
    >> > TIA
    >> > Cheers
    >> > Mark
    >> >
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
    Daniel Walzenbach, Sep 5, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    8
    Views:
    2,228
    tshad
    Oct 19, 2005
  2. Paul Aspinall

    Databinding DropDownList and Label

    Paul Aspinall, Feb 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    539
    =?Utf-8?B?RFdT?=
    Feb 6, 2006
  3. Replies:
    0
    Views:
    517
  4. jobs
    Replies:
    0
    Views:
    1,618
  5. Earl Teigrob
    Replies:
    1
    Views:
    401
    Shravan
    Mar 1, 2004
Loading...

Share This Page