我在gridview中的行
<asp:Label ID="Label2" runat="server" Text='<%# new System.Text.StringBuilder("<a href=\"/Administration/Pages/EditPage/?pageID=").Append(Eval("PageID")).Append("\">").Append(Eval("Name")).Append("</a>").ToString() %>'></asp:Label>
失败了
异常详细信息:System.Web.HttpException:DataBinding:“System.Data.DataRowView”不包含名为“PageID”的属性。
我怀疑问题是数据源中的别名
SelectCommand="SELECT Menus.ID, Menus.ParentID, Menus.Name, Menus.Slug, Menus.PageTitle, Menus.PageSubTitle, Menus.MenuOrder, Menus.IsHomePage, Menus.IsYourAccountLink, Menus.IsMiniMenu, Menus.IsFooterMenu, Menus.IsHeaderMenu, Menus.CustomerID, Customers.SubDomain, PublicPages.ID AS PageID FROM Menus INNER JOIN Customers ON Menus.CustomerID = Customers.ID INNER JOIN PublicPages ON Menus.ID = PublicPages.HeaderMenuID AND Customers.ID = PublicPages.CustomerID WHERE (Menus.CustomerID = @CustomerFilter)"
那么如何将其用作别名:
Append(Eval("PageID"))
谢谢