2012-02-06 49 views
3

出現以下錯誤: 在所選數據源上找不到名稱爲「PageId」的字段或屬性。在選定的數據源上找不到屬性

如果PageId不在對象中,這將會使其成爲可能 - 但它是。下面是ASPX:

<asp:UpdatePanel EnableViewState="true" UpdateMode="Conditional" ID="pnlPagesDislay" runat="server"> 
     <ContentTemplate> 
      <asp:GridView ID="grdMediaFilesetPages" AllowSorting="false" AllowPaging="false" runat="server" AutoGenerateColumns="False" OnRowCommand="grdMediaFilesetPages_RowCommand" CellPadding="2" ForeColor="#333333" GridLines="None" Width="1000px"> 
       <FooterStyle BackColor="#49a4d4" Font-Bold="True" ForeColor="White" /> 
       <Columns> 
        <asp:BoundField DataField="PageId" HeaderText="Page ID" InsertVisible="False" ReadOnly="True"> 
         <HeaderStyle HorizontalAlign="Left" Wrap="true" /> 
        </asp:BoundField> 
        <asp:BoundField DataField="LayoutId" HeaderText="Layout" InsertVisible="False" ReadOnly="True"> 
         <HeaderStyle HorizontalAlign="Left" /> 
        </asp:BoundField> 
        <asp:BoundField DataField="Images" HeaderText="Images" InsertVisible="False" ReadOnly="True"> 
         <HeaderStyle HorizontalAlign="Left" Wrap="true" /> 
        </asp:BoundField> 
        <asp:TemplateField HeaderText="Actions" AccessibleHeaderText="Actions" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right"> 
         <ItemTemplate><span style="white-space:nowrap"> 
         <a href="<%# DataBinder.Eval(Container.DataItem, "EditLink") %>">Edit</a>&nbsp;|&nbsp; 
         <asp:LinkButton ID='RemoveLinkBtn' Text='Remove' CommandName='RemoveLanguageAttr' CommandArgument='<%# DataBinder.Eval(Container.DataItem, "LangAttrId") %>' runat='server' /> 
         </span> 
         </ItemTemplate> 
        </asp:TemplateField> 
       </Columns> 
       <RowStyle BackColor="#EFF3FB" /> 
       <EditRowStyle BackColor="#2461BF" /> 
       <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> 
       <PagerStyle BackColor="#49a4d4" ForeColor="White" HorizontalAlign="Center" /> 
       <HeaderStyle BackColor="#49a4d4" Font-Bold="True" VerticalAlign="Bottom" ForeColor="White" Wrap="true" /> 
       <AlternatingRowStyle BackColor="White" /> 
      </asp:GridView> 
     </ContentTemplate> 
    </asp:UpdatePanel> 

這裏是後面的代碼:

_mediaFilesetPages = new List<MediaFilesetPage> {new MediaFilesetPage 
               { 
                EditLink = "", 
                ID = "", 
                ImageFile = "testing.png", 
                LayoutId = "1", 
                PageId = "0001", 
                RemoveLink = "" 
               }}; 
grdMediaFilesetPages.DataSource = _mediaFilesetPages; 
grdMediaFilesetPages.DataBind(); 

這裏是MediaFilesetPage對象:

internal class MediaFilesetPage 
{ 
    public string ID; 
    public string PageId; 
    public string LayoutId; 
    public string ImageFile; 
    public string EditLink; 
    public string RemoveLink; 
} 

任何人有任何的問題是什麼什麼想法?

+0

我想通了。但我不能發佈7個小時的答案,因爲我沒有100的聲譽。我會盡我所能發佈。 – dcinadr 2012-02-06 18:36:42

回答

3

讓你的領域進行的公共屬性:

internal class MediaFilesetPage 
{ 
    public string ID {get; set; } 
    public string PageId {get; set; } 
    public string LayoutId {get; set; } 
    public string ImageFile {get; set; } 
    public string EditLink {get; set; } 
    public string RemoveLink {get; set; } 
} 
+0

猜猜我不需要等7個小時才能發佈答案。多謝,夥計。 – dcinadr 2012-02-06 22:10:15

相關問題