DataBinding:“System.Data.DataRowView”不包含名为“DocID”的属性

本文关键字:DocID 属性 包含名 System Data DataRowView DataBinding | 更新日期: 2023-09-27 18:36:45

我尝试此查询以仅查看通过其帐户方式上传的文档用户仅查看自己的文档查询

 ALTER procedure [dbo].[dddddd]
   @userid int
   as                     
   SELECT DISTINCT DocumentInfo.DocID as DocumentID ,
    dbo.DocumentInfo.DocName as DocumentName,
    dbo.DocumentInfo.Uploadfile as FileUploaded,
    dbo.DocType.DocType as Document,
    dbo.Department.DepType as Department ,
    dbo.ApproveType.ApproveType AS ApproveID
    FROM dbo.DocumentInfo
    inner JOIN dbo.DocType ON dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID
    inner JOIN dbo.Department ON dbo.DocumentInfo.DepID=dbo.Department.DepID
    LEFT JOIN dbo.ApproveType ON    
     dbo.ApproveType.approveid=dbo.DocumentInfo.ApproveID   
    LEFT    
    OUTER JOIN
    Approval a ON a.DocID = a.DocID
    JOIN
    ApproveType at ON at.ApproveID = ISNULL(a.Approveid, 3)  where UserID=@userid

但它向我显示错误

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'DocID'."

在这一行中

  <td><%#DataBinder.Eval(Container.DataItem,"DocID") %></td>

错误在哪里

DataBinding:“System.Data.DataRowView”不包含名为“DocID”的属性

查询

中没有返回 DocID,因为您已为要DocumentID的列设置了别名。

改为改为:

 <td><%#DataBinder.Eval(Container.DataItem,"DocumentID") %></td>

你的left outer join是否正确?您似乎在查询的两端使用相同的表。更多的是一种观察。