2014年7月13日 星期日

[RESOLVED] user id not found in asp.net


i use gridview like this

 

then when i debug it shows me error

 



"A field or property with the name 'UserID' was not found on the selected data source.

 



<asp:GridView ID="GridView1" runat="server" Width="100%" 
AutoGenerateColumns="false" GridLines="None">
<Columns>
<asp:BoundField HeaderText="UserID" DataField="UserID" ItemStyle-BackColor="#EFEFEF" />
<asp:BoundField HeaderText="DocName" DataField="DocName" ItemStyle-BackColor="#EFEFEF" />
<asp:BoundField HeaderText="UploadFile" DataField="UploadFile" />
<asp:BoundField HeaderText="DocType" DataField="DocType" />
<asp:BoundField HeaderText="DepType" DataField="DepType" />
<%--"StandardCost" DataField="StandardCost" />
"ListPrice" DataField="ListPrice" />
"Weight" DataField="Weight" />
"SellStartDate" DataField="SellStartDate" /> --%>
</Columns>
<HeaderStyle CssClass="GridviewScrollHeader" />
<RowStyle CssClass="GridviewScrollItem" />
<PagerStyle CssClass="GridviewScrollPager" />
</asp:GridView>


Sounds to me like you're databinding the grid to a data source that doesn't include a UserID field/column. 



Check your query

query is



ALTER procedure [dbo].[spgetfile]

as

select dbo.Document.DocID,dbo.Document.DocName,dbo.Document.Uploadfile,dbo.DocType.DocType,dbo.Department.DepType

from dbo.Document left join dbo.DocType on dbo.Document.DocTypeID=dbo.DocType.DocTypeID left join


dbo.Department on dbo.Document.DepID=dbo.Department.DepID


沒有留言:

張貼留言