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

Proj_Edit.aspx


                AllowSorting="True" AutoGenerateColumns="False" AutoGenerateDeleteButton="True"
                CellPadding="5" DataKeyNames="货号" DataSourceID="AccessDataSource1"
                ForeColor="#333333" GridLines="None" PageSize="18" Width="715px"
                style="text-align: left">
               
               
                                            InsertVisible="False" ReadOnly="True" />
                   
                   
                   
                   
                   
               

               
               
               
               
               
               
               
               
               
               
           

 

                                   DataFile="~/App_Data/Proj.mdb"
                    SelectCommand="SELECT * FROM [Proj] ORDER BY [货号] DESC">
               

 

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();
        }

你可能感兴趣的:(ASP.NET,sql,asp,textbox,server,button,object)