1
我需要在C#中得到名稱的子在ASP的BoundField對於知道名稱子我的已使用DirectoryInfo獲取目錄的名稱中的DirectoryInfo在數據綁定在C#
在編碼我有這個錯誤:
字段或屬性具有名稱「姓名」是不低於
我的代碼所選擇的 數據源中找到。
你能幫我嗎?
預先感謝您的任何幫助,真的很感激。
的.cs
using (DataSet ds =
new DataSet())
{
DataTable dt =
new DataTable();
sda.Fill(ds);
sda.Fill(dt);
dt = ds.Tables[0];
string FilePath = HttpContext.Current.Server.MapPath("/myfolder/" + ds.Tables[0].Rows[0]["sFolder"].ToString().Replace('/', '\\'));
HttpContext.Current.Response.Write(FilePath + "<br /><br />");
DirectoryInfo directory = new DirectoryInfo(@FilePath);
DirectoryInfo[] subDirectories = directory.GetDirectories();
foreach (DirectoryInfo dirInfo in subDirectories)
HttpContext.Current.Response.Write(dirInfo.Name + "<br />");
return dt;
}
的.aspx
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false"
CssClass="mGrid" Width="500" HorizontalAlign="Center"
DataKeyNames="ID" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Folder name" />
</Columns>
</asp:GridView>