开发者

How to Split comma seperate DataItem field in GridView Eval?

开发者 https://www.devze.com 2023-02-16 17:30 出处:网络
here my code- <asp:TemplateField HeaderText=\"HIGH RISK (10-12)\" ItemStyle-HorizontalAlign=\"Center\">

here my code-

 <asp:TemplateField HeaderText="HIGH RISK (10-12)" ItemStyle-HorizontalAlign="Center">
      <ItemTemplate>
           <asp:Label ID="lblHighrisk" runat="server" Text='<%# Eval("URANGE").ToString().Split('-')[0] %>' />
      </ItemTemplate>
 </asp:TemplateField>

but开发者_StackOverflow that is giving compile time error 'Server tag is not well formed'


Perhaps you have a problem with the quotation marks in the second split?

try

 Text='<%# Eval("URANGE").ToString().Split("-")[0] %>'

does that help?

Update after comment Yes, that makes sense

Try reversing the quotation in that case

 Text="<%# Eval'URANGE').ToString().Split('-')[0] %>"

does that help?


Try it without quotes:

<asp:Label ID="lblHighrisk" runat="server" 
     Text=<%# Eval("URANGE").ToString().Split('-')[0] %> />


It will be ok when you convert string "." to char and post it to split method.

Text='<%# Eval("costIntegerPart").ToString().Split(Convert.ToChar("."))[0] %>'


This will work

style='<%#Eval("cssHover").ToString().Split(new string[]{";"},StringSplitOptions.None)[0]%>'
0

精彩评论

暂无评论...
验证码 换一张
取 消