XML Binding to Datagrid


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: XML Binding to Datagrid

  1. #1
    s Guest

    XML Binding to Datagrid


    When I Bind this document to the datagrid I get an Error: 'A field or property
    with the name 'Display' was not found on the selected datasource.'

    Why I am getting this error it is finding the time interval column

    HTML Code
    <asp:datagrid id="dg" runat="server" autogeneratecolumns="False">
    <columns>
    <asp:boundcolumn datafield="TimeInterval" readonly="True"> </asp:boundcolumn>
    <asp:boundcolumn datafield="Display"></asp:boundcolumn>
    </columns>
    </asp:datagrid>

    My XML Document Sample
    <?xml version="1.0" encoding="utf-8" ?>
    <TimeSlot>
    <TimeInterval>00:30</TimeInterval>
    <Display>Department Meeting</Display>
    </TimeSlot>
    <TimeSlot>
    <TimeInterval>01:00</TimeInterval>
    <Display>Test Setup 1</Display>
    <Display>Test Setup 2</Display>
    </TimeSlot>
    <TimeSlot>
    <TimeInterval>01:30</TimeInterval>
    </TimeSlot>
    <TimeSlot>
    <TimeInterval>02:00</TimeInterval>
    </TimeSlot>
    <TimeSlot>
    <TimeInterval>02:30</TimeInterval>
    </TimeSlot>
    <TimeSlot>
    <TimeInterval>03:00</TimeInterval>
    <Display>Meeting 3:00 Jon Doe</Display>
    <Display>Meeting 3:00 Jane Doe</Display>
    </TimeSlot>

    MY asp.NET code in VB

    Dim doc As System.Xml.XmlDataDocument = New System.Xml.XmlDataDocument()
    Dim nsArray() As String

    doc.DataSet.InferXmlSchema(Server.MapPath("XMLFile1.xml"), nsArray)
    doc.Load(Server.MapPath("XMLFile1.xml"))
    dg.DataSource = doc.DataSet
    dg.DataBind()

  2. #2
    alkemy Guest

    Re: XML Binding to Datagrid


    XML File Should look Like this


    <?xml version="1.0" encoding="utf-8" ?>
    <TimeSlot>
    TimeInterval = 03:00
    Display = Meeting 3:00 Jon Doe
    </TimeSlot>
    <TimeSlot>
    TimeInterval = 03:00
    Display = Meeting 3:00 Jon Doe
    </TimeSlot>
    <TimeSlot>
    TimeInterval = 03:00
    Display = Meeting 3:00 Jon Doe
    </TimeSlot>
    <TimeSlot>
    TimeInterval = 03:00
    Display = Meeting 3:00 Jon Doe
    </TimeSlot>

  3. #3
    Guest

    Re: XML Binding to Datagrid


    "alkemy" <t_t_t@j_j_j.com> wrote:
    >
    >XML File Should look Like this
    >
    >
    ><?xml version="1.0" encoding="utf-8" ?>
    ><TimeSlot>
    > TimeInterval = 03:00
    > Display = Meeting 3:00 Jon Doe
    ></TimeSlot>
    ><TimeSlot>
    > TimeInterval = 03:00
    > Display = Meeting 3:00 Jon Doe
    ></TimeSlot>
    ><TimeSlot>
    > TimeInterval = 03:00
    > Display = Meeting 3:00 Jon Doe
    ></TimeSlot>
    ><TimeSlot>
    > TimeInterval = 03:00
    > Display = Meeting 3:00 Jon Doe
    ></TimeSlot>


    No I want the Time intervale in the grid to be displayed once. The Display
    Columns could be 0 to n depending on the number of events that start at that
    interval.

    Layout should look like.

    Interval Display
    3:00 Meeting Jon Doe
    Meeting Jane Doe
    3:30
    4:00 Go Home
    4:30 Get Haircut
    Pickup Kids
    Go Eat
    5:00



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center