Introducing LINQ to SQL Designer using Visual Studio 2008 - Creating a simple LINQ to SQL application: fetching information onto a web page
(Page 2 of 5 )
The following steps are continued from the previous section
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="SampleVB._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnSelectStar" runat="server" Text="Select *" />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>
</body>
</html>
Imports System.Data.Linq
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub btnSelectStar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSelectStar.Click
Dim db As New SampleDBDataContext
Me.GridView1.DataSource = db.emps
Me.GridView1.DataBind()
End Sub
End Class
That's all. Once you press F5, you should see the following output (Fig 07):

Next: Creating a simple LINQ to SQL application: updating information to the database >>
More .NET Articles
More By Jagadish Chaterjee