2011-07-18 23 views
12

adıyla bir özellik içermiyor Bu garip hata alıyorum ... veritabanımdaki birincil anahtar 'DocumentID' olduğundan sorun olmadığını biliyorum. Seçimi almaya çalışıyorum, & delete greyview düğmelerini çalışmam için düzeltin ama kullanmaları için doğru olarak ayarlanacak datakeynameslere ihtiyacım var. herhangi bir fikir? İşte DataBinding: 'System.Data.DataRowView',

<asp:GridView ID="GridView1" runat="server" DataSourceID="sdsDocuments" EnableModelValidation="True" 
     SelectedIndex="0" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" DataKeyNames="DocumentID, DocumentTitle, DocumentBody"> 
     <Columns> 
      <asp:BoundField DataField="DocumentID" HeaderText="DocumentID" ReadOnly="True" SortExpression="ID" /> 
      <asp:BoundField DataField="DocumentTitle" HeaderText="DocumentTitle" SortExpression="Title" /> 
      <asp:BoundField DataField="DocumentBody" HeaderText="DocumentBody" SortExpression="Body" /> 
      <asp:CommandField ShowSelectButton="True" ShowDeleteButton="True" /> 
     </Columns> 
    </asp:GridView> 
    <asp:SqlDataSource ID="sdsDocuments" runat="server" ConnectionString="<%$ ConnectionStrings:blcDocumentationConnectionString %>" 
     SelectCommand="SELECT [DocumentTitle], [DocumentBody] FROM [tblDocument]" /> 

[HttpException (0x80004005): DataBinding: 'System.Data.DataRowView' does not contain a     property with the name 'DocumentID'.] 
     System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +8672869 
     System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2178 
     System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57 
     System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14 
     System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114 
     System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31 
     System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142 
     System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73 
     System.Web.UI.WebControls.GridView.DataBind() +4 
     System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82 
     System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72 
     System.Web.UI.Control.EnsureChildControls() +87 
     System.Web.UI.Control.PreRenderRecursiveInternal() +44 
     System.Web.UI.Control.PreRenderRecursiveInternal() +171 
     System.Web.UI.Control.PreRenderRecursiveInternal() +171 

    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842 

cevap

6

ve dolayısıyla Datatable veya DataView'e sen ızgaraya bağlama VEYA o başvuran ya mevcut değil:

Belki bu kadar veri kaynağı tanımını değiştirmelisiniz datatable üzerinden sütun.

SelectCommand="SELECT [DocumentID],[DocumentTitle], [DocumentBody] FROM [tblDocument]" /> 
sorgunuzu değiştirin

0

sizin sqldatasource DocumentId sütunu dönmez görünüyor ... yığın izidir. Eğer seçmediniz, Eh documentid sütunu

<asp:SqlDataSource ID="sdsDocuments" runat="server" ConnectionString="<%$ ConnectionStrings:blcDocumentationConnectionString %>" 
    SelectCommand="SELECT [DocumentID], [DocumentTitle], [DocumentBody] FROM [tblDocument]" /> 
İlgili konular