开发者

asp.Net ListView/GridView Databound Error

I am attempting to use a GridView in asp using VB and I get an error message about content. I did some research and reformatted the XML document the datasource is referencing but still cant seem to get the GridView to generate.

Error Message: "The data source for GridView with id 'GridView1' did not have any properties or attributes from which to generate columns. Ensure that your data source has content."

XML Snippet:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<financialExpenditures2>
    <expenses>
        <expense Reporting="" Obj="val" Sub-Obj="" Doc_Code="val" Doc_Dep="val" Document_ID="val" Record_Date="val" FY="val" BFY="val" Acct_Per="val" Fund="val" Department="val" Unit="val" Sub-unit="" Activity="val" Vendor_Code="" Vendor_Name="" Check_Num="" Vendor_Invoice_Num="" Posting_Code="val" Sub_unit="" Posting_Amt="val" Comm_Ln_Num="val" Acct_Ln_Num="val" Accounting_Line_Desc="longer string val"/>
    </expenses>
</financialExpenditures>

View Page Code

<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplication2._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h开发者_运维技巧2>
        Welcome to ASP.NET!
    </h2>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" DataSourceID="conversionBook2">
        </asp:GridView>
        <asp:XmlDataSource ID="conversionBook2" runat="server" 
            DataFile="~/conversionBook2.xml"></asp:XmlDataSource>
    </div>    
    </form> 
</asp:Content>


it looks like your xml file isn't quite right. removing the financialExpenditures tags gets things working.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<expenses> 
    <expense Reporting="" Obj="val" Sub-Obj="" Doc_Code="val" Doc_Dep="val" Document_ID="val" Record_Date="val" FY="val" BFY="val" Acct_Per="val" Fund="val" Department="val" Unit="val" Sub-unit="" Activity="val" Vendor_Code="" Vendor_Name="" Check_Num="" Vendor_Invoice_Num="" Posting_Code="val" Sub_unit="" Posting_Amt="val" Comm_Ln_Num="val" Acct_Ln_Num="val" Accounting_Line_Desc="longer string val"/> 
</expenses> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜