split field by comma

G

Guest

How can I split a field that is being displayed as an asp:label with a dataview? Currently the field is being displayed using this code
<asp:label id=dept runat="server" Font-Size="Smaller" Font-Names="Arial" Text='<%# DataBinder.Eval(DataView1, "[0].CATEGORY_APPROVER")%>'></asp:label
What can I add to get it to split by comma? I need it to also line break after each comma. I'm a beginner and don't know how to modify the code to get the split

Please help

Paol
 
D

Darren Clark

string res = e.CommandArgument.ToString();

string delimStr = ",";

char [] delimiter = delimStr.ToCharArray();

string[] vals = res.Split(delimiter);

string s = vals[0].ToString();

string x = vals[1].ToString();

string s2 = vals[2].ToString();
 
K

Ken Cox [Microsoft MVP]

If you need a line break where the comma is, can you just use replace() to
change the comma into "<br />" ?
 
G

Guest

Thanks Darren but where do i put this code? This looks like i can't use my label call? sorry, jus learning .net
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top