asp:DropDownList and databinding

M

Mark

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
 
D

Daniel Walzenbach

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
 
M

Mark

Hi Daniel, great, that's it :)
Thanks
Mark
Daniel Walzenbach said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top