Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在listview中拆分Container.DataItem字符串_C#_Asp.net - Fatal编程技术网

C# 如何在listview中拆分Container.DataItem字符串

C# 如何在listview中拆分Container.DataItem字符串,c#,asp.net,C#,Asp.net,我有一个列表,它返回这种格式的字符串yyyy-MM-dd;价格。此列表绑定到我的listview,我想将字符串拆分为listview的两个字段:第一个字段包含yyyy MM dd,第二个字段包含价格 这是我试过的 <asp:Label ID="lblCodeUsager" runat="server" Text='<%# Container.DataItem.ToString().Split(';')[0] %>' />

我有一个
列表
,它返回这种格式的字符串
yyyy-MM-dd;价格
。此列表绑定到我的listview,我想将字符串拆分为listview的两个字段:第一个字段包含yyyy MM dd,第二个字段包含价格

这是我试过的

<asp:Label ID="lblCodeUsager" 
           runat="server" 
           Text='<%#  Container.DataItem.ToString().Split(';')[0] %>' />

不幸的是,我得到一个错误,说服务器标记不正确

我知道我可以传递一个对象列表,但我想知道是否有一个包含字符串列表的解决方案?


<asp:Label ID="lblCodeUsager" 
       runat="server" 
       Text="<%#  Container.DataItem.ToString().Split(';')[0] %>" />

您需要将“for the text”属性替换为“for the text”,因为如果不这样做,它将干扰拆分。

尝试
\'
,而不仅仅是
'
。或者创建一个类列表,而不是预处理信息