split field by comma

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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();
 
If you need a line break where the comma is, can you just use replace() to
change the comma into "<br />" ?
 
Thanks Darren but where do i put this code? This looks like i can't use my label call? sorry, jus learning .net
 
Back
Top