Click here to Skip to main content
15,904,153 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey all


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.NET
<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" /> 
        <%--<asp:BoundField HeaderText="StandardCost" DataField="StandardCost" /> 
        <asp:BoundField HeaderText="ListPrice" DataField="ListPrice" /> 
        <asp:BoundField HeaderText="Weight" DataField="Weight" /> 
        <asp:BoundField HeaderText="SellStartDate" DataField="SellStartDate" /> --%>
    </Columns> 
    <HeaderStyle CssClass="GridviewScrollHeader" /> 
    <RowStyle CssClass="GridviewScrollItem" /> 
    <PagerStyle CssClass="GridviewScrollPager" /> 
</asp:GridView> 
Posted
Comments
[no name] 22-Sep-13 8:39am    
And does your data source contain a field named "UserID"?
Diya Ayesa 22-Sep-13 9:35am    
yes
Zubair Alie 22-Sep-13 9:07am    
DataField is the name of column inside your datasource. If your datasource is either NULL or does not contail column UserID atleast then you are expected must to receeive the error you reported here.

Note: Put your cs page under debug mode and look onto your datasource in Quick Watch and fix the issue you are running with.

Good Luck :)

1 solution

i just rename userid to docid beacuse userid column is not in table
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900