Wednesday, September 24, 2008

Monday, September 22, 2008

Filling a dropdownlist with LINQ

Partial Public Class _Default
Inherits System.Web.UI.Page

Dim northwind As New northwindDataContext()

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not IsPostBack Then
Dim categories = From categorie In northwind.Categories _
Select categorie
DropDownList1.DataSource = categories
DropDownList1.DataTextField = "CategoryName"
DropDownList1.DataValueField = "CategoryID"
End If

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim selectValue = DropDownList1.SelectedItem.Value
Dim products = From product In northwind.Products _
Where product.CategoryID = selectValue
GridView1.DataSource = products
End Sub

End Class

The ASPX Page

<form id="form1" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<hr />
<asp:GridView ID="GridView1" runat="server">

Transmit Forms Data to another ASP.NET page

A dicscussion a bout this problem
And from Microsoft

Sunday, September 21, 2008


Simple Query Sample

Module Module1

Sub Main()
Dim doc = XDocument.Load("c:\books.xml").Elements
Dim query = From data In doc.Elements _
Where data.Element("title") = "Python"
For Each g In query
End Sub

End Module

Sample File


LINQ to XML Samples

A few samples on querying XML with LINQ

Creating Custom Configuration Sections in Web.config

From Scott Mitchell