将AccessDataSource移动到vb后面的代码中

时间:2018-04-11 20:45:55

标签: vb.net aspxgridview

希望将几十页从aspx AccessDataSource转换为vb.net代码。我在其他页面上使用OleDB和ADO。想知道是否有任何固定代码将简单的select语句绑定到GridView1

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataSourceID="AccessDataSource1" BackColor="White" BorderColor="#999999" 
    BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" 
    GridLines="Vertical" AllowSorting="True">
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
        <asp:CheckBox ID="RowLevelCheckBox" runat="server" />
    </ItemTemplate>
    </asp:TemplateField>
        <asp:BoundField DataField="UsersDataTbl.LastName" HeaderText="Last Name" SortExpression="LastName" />
        <asp:BoundField DataField="UsersDataTbl.FirstName" HeaderText="First Name" SortExpression="FirstName" />
        <asp:BoundField DataField="UsersDataTbl.Affiliation" HeaderText="Affiliation" SortExpression="Affiliation" />
        <asp:BoundField DataField="UsersDataTbl.UID" HeaderText="UID" SortExpression="UID" />
    </Columns>
    <FooterStyle BackColor="#CCCCCC" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="#6699CC" />
</asp:GridView>


<asp:AccessDataSource ID="AccessDataSource1" runat="server" 
DataFile="<%$ ConnectionStrings:AccessSubSiteString %>"
    SelectCommand="SELECT [UsersDataTbl.LastName], [UsersDataTbl.FirstName], [UsersDataTbl.Affiliation], [UsersDataTbl.UID], [ALSProviders.ALS] 
    FROM [UsersDataTbl] LEFT JOIN [ALSProviders] ON (UsersDataTbl.UID = ALSProviders.UID) WHERE [UsersDataTbl.Career] = True 
    AND [UsersDataTbl.Active] = True AND ([UsersDataTbl.UID] NOT IN (SELECT UID FROM [ALSProviders]))
    ORDER BY [UsersDataTbl.LastName]" >
    <SelectParameters>         
    </SelectParameters>
</asp:AccessDataSource>

0 个答案:

没有答案