Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a datalist item i bind the week days. i put the comma in grid view in how to remove last comma only...
i write like this
XML
<asp:DataList ID="dlstWeekDays" runat="server"  RepeatColumns="7" RepeatDirection="Horizontal" ;
    <ItemStyle Width="50px" Font-Size="12px"  />
    <ItemTemplate>                                            <%#Eval("Lookup.Code")%>,
  </ItemTemplate>
       </asp:DataList>



i get out put like this
Working days :

Monday, Tuesday, Wednesday, Thursday, Friday,

i want remove after "Friday" only not this "Friday,"
Posted

1 solution

HTML
<%#Eval("Lookup.Code.TrimEnd(',')")%>,
 
Share this answer
 
v2
Comments
Kolli Hari Chowdary 10-Nov-12 4:55am    
Sorry
i get this error "DataBinding: 'System.String' does not contain a property with the name 'TrimEnd'".
bbirajdar 10-Nov-12 4:58am    
Seems , TrimEnd is not working when in declarative syntax. Then you will have to use TrimEnd at backend from where this Lookup.Code is returning the data. Use this in the code-behind
Kolli Hari Chowdary 10-Nov-12 5:12am    
in dlstWeekDays does not suppert
can u give any eg like this
bbirajdar 10-Nov-12 10:01am    
Okay.. Tell me from where are you getting this "Lookup.Code" ..Show me the code related to this "Lookup.Code"
bbirajdar 10-Nov-12 10:03am    
If this is a property like this

public Lookup.Code { return Lookup.Code ="Monday,...Friday," }

Then I will fix it as

public Lookup.Code { return Lookup.Code ="Monday,...Friday,".TrimEnd(','); }

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900