<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_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>利用LingDataSource控件访问数据库</title>
    <style type="text/css">
        .style1
        {
            font-size: x-large;
            font-weight: bold;
            font-family: 华文新魏;
            color: #008000;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table align="center" style="width: 650px; height: 259px;">
            <tr>
                <td align="center" class="style1" >
                    利用LingDataSource控件访问数据库<br />
                </td>
            </tr>
            <tr>
                <td align="center" >
                    <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                        ContextTypeName="DataClassesDataContext" Select="new (职工号, 仓库号, 姓名, 性别, 工资)" 
                        TableName="职工">
                    </asp:LinqDataSource>
                    <br />
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" 
                        CellPadding="2" DataSourceID="LinqDataSource1" ForeColor="Black" 
                        GridLines="None" Height="203px" Width="560px">
                        <FooterStyle BackColor="Tan" />
                        <Columns>
                            <asp:BoundField DataField="职工号" HeaderText="职工号" ReadOnly="True" 
                                SortExpression="职工号" />
                            <asp:BoundField DataField="仓库号" HeaderText="仓库号" ReadOnly="True" 
                                SortExpression="仓库号" />
                            <asp:BoundField DataField="姓名" HeaderText="姓名" ReadOnly="True" 
                                SortExpression="姓名" />
                            <asp:BoundField DataField="性别" HeaderText="性别" ReadOnly="True" 
                                SortExpression="性别" />
                            <asp:BoundField DataField="工资" HeaderText="工资" ReadOnly="True" 
                                SortExpression="工资" />
                        </Columns>
                        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" 
                            HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
                        <HeaderStyle BackColor="Tan" Font-Bold="True" />
                        <AlternatingRowStyle BackColor="PaleGoldenrod" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>
