• 利用修改AccessDataSource的sql语句来检索数据


    Proj_Edit.aspx


    --------------------------------------------------------------------------------

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
                    AllowSorting="True" AutoGenerateColumns="False" AutoGenerateDeleteButton="True"
                    CellPadding="5" DataKeyNames="货号" DataSourceID="AccessDataSource1"
                    ForeColor="#333333" GridLines="None" PageSize="18" Width="715px"
                    style="text-align: left">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="货号" HeaderText="货号" SortExpression="货号"
                            InsertVisible="False" ReadOnly="True" />
                        <asp:BoundField DataField="名称" HeaderText="名称" SortExpression="名称" />
                        <asp:BoundField DataField="图片" HeaderText="图片" SortExpression="图片" />
                        <asp:BoundField DataField="主页地址" HeaderText="主页地址" SortExpression="主页地址" />
                        <asp:BoundField DataField="所属分类" HeaderText="所属分类" SortExpression="所属分类" />
                        <asp:BoundField DataField="排名竞价" HeaderText="排名竞价" SortExpression="排名竞价" />
                    </Columns>
                    <EditRowStyle BackColor="#2461BF" />
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                </asp:GridView>

                   <asp:AccessDataSource ID="AccessDataSource1" runat="server"
                        DataFile="~/App_Data/Proj.mdb"
                        SelectCommand="SELECT * FROM [Proj] ORDER BY [货号] DESC">
                    </asp:AccessDataSource>

    Proj_Edit.aspx.cs


    --------------------------------------------------------------------------------

    protected void Button1_Click(object sender, EventArgs e)
            {
                string sql = "SELECT * FROM Proj  WHERE 名称 like '%" + TextBox1.Text.Trim() + "%' ORDER BY 排名竞价 DESC";
                AccessDataSource1.SelectCommand = sql;
                GridView1.DataBind();
            }

  • 相关阅读:
    django中间件和常用模块
    django之forms组件
    django和ajax、分页器、批量插入数据
    django之模型层ORM操作
    (专题三)02-1 程序和程序设计流程-选择结构
    (专题三)01 程序和程序设计流程-顺序结构
    (专题二)05 矩阵的存储方式
    (专题二)04 矩阵的处理-矩阵的特征值
    [代码片段]YEAH!连通域标记和计数
    TTL和CMOS
  • 原文地址:https://www.cnblogs.com/mane/p/1829935.html
Copyright © 2020-2023  润新知