Site Search:
Sign in | Join | Help

This Blog

Syndication

VB.NET

Notes, Tricks and Tips on VB.NET

August 2008 - Posts

  • Linq to XML with ASP Gridview in VB

     XML FILE:

    <seriesSermons>

    <series>

    <title>Building</title>

    <desc>As we enter into the construction phase of our building project, Pastor Campbell brings a series on building. Building not only walls and doors, but lives.</desc>

    <author>Dr. Mark Campbell</author>

    <details>

    <date>20080824 Sun AM</date> <file>Building with Prayer</file>

    <description>

    Nehemiah 2:1-11

    From old testament and new, Pastor Campbell continues the series on building. This week - building with prayer.

    </description>

    </details>

    <details>

    <date>20080817 Sun AM</date>

    <file>Building with Prayer</file>

    <description>

    Nehemiah 1:1-11

    As our new building is set to begin, Pastor Campbell begins a series in Nehemiah - God’s building story.

    </description>

    </details>

    </series>

    <series>

    <title>Acts</title>

    <desc>

    Pastor Campbell continues our weekly bible study in Acts

    </desc>

    <author>Dr. Mark Campbell</author>

    <details>

    <date>20080720 Wed PM</date>

    <file>Acts 26</file>

    <description>

    Pastor Campbell continues our weekly bible study in Acts

    </description>

    </details>

    <details>

    <date>20080806 Wed PM</date>

    <file>Acts 26</file>

    <description>

    Acts 26:19-20

    Pall continues his defense before King Agrippa

    </description>

    </details>

    </series>

    </seriesSermons>

    Imports:

    Imports System.Xml.Linq

    Imports System.Linq 

    VB Code Behind:  Page Load()

    Dim strTitle As String = Request.QueryString("id")

    Dim seriesXML As XDocument = XDocument.Load(Server.MapPath("/XML/seriesSermons.xml"))

     

    Dim var = From series In seriesXML.Descendants("series") _               

                   Where series.Elements("title").Value = strTitle

     

    Dim det = From details In var.Descendants("details") _

                  Select strDate = details.Element("date").Value, _

                                   file = details.Element("file").Value, _

                                 desc = details.Element("description").Value()

     

    gvSeriesDetail.DataSource = det.ToList()

    gvSeriesDetail.DataBind()