【发布时间】:2016-04-25 10:46:48
【问题描述】:
我有一个问题,我有一个使用 c# 的方法,我在其中读取了包含文件夹路径的长文本。通过使用正则表达式将其分解,我保存了一个我想在我的网格视图中显示的小文本。代码是这样的
string folder = @"X:\05_General\T\TestVehicleInfo\Vehicles\Bordeaux_2099908\Readouts\All\20160126_22138km_RESF_Tw1602\After\XCOM\Bordeaux_2099908_20160128_22159km_XCOM_ALL_DTC_CDABX1.txt";
string[] parts = folder.Split('\\');
List<string> filteredstrings = new List<string>();
foreach (string part in parts)
{
if (Regex.IsMatch(part, @"\d{8}"))
{
filteredstrings.Add(part);
}
}
gridview 看起来像这样:
<asp:BoundField DataField="ReadOutID" HeaderText="ReadOutID" InsertVisible="False" ReadOnly="True" SortExpression="ReadOutID" />
<asp:BoundField DataField="FileName" HeaderText="FileName" SortExpression="FileName" />
<asp:BoundField DataField="FileTime" HeaderText="FileTime" SortExpression="FileTime" />
<asp:BoundField DataField="ImportTime" HeaderText="ImportTime" SortExpression="ImportTime" />
<%-- <asp:BoundField DataField="FullPath" HeaderText="Comment" SortExpression="FullPath" />--%>
<asp:TemplateField HeaderText="Comment" SortExpression="FullPath">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FullPath") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# **What should i write here?** %>'></asp:Label>
</ItemTemplate>
我想在我写“我应该在这里写什么”的 asp:label 区域中显示过滤后的字符串。我应该使用什么命令?
【问题讨论】:
-
你是从
DataTable..填充gridview吗? -
是的!来自 SQL 源
-
既然你有 List
你想在gridview中显示,对吧..?? -
你可以使用
Eval -
您可以在
DataTable中添加一列并根据行,只需用您的字符串填充新列,然后绑定BoundField通常的方式。
标签: c# asp.net gridview itemtemplate