这段是查询控件代码
protected void BtnSearch_Click(object sender, EventArgs e)
{
if (this.txtstart.Text==""&&this.txtwhither.Text=="")
{
this.Response.Write("不能为空!");
}
else
{
this.Response.Redirect(showmessage.aspx?UID=this.txtstart&DestD=this.txtwhither);
}
}
下面这段是查询结果显示代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data;
public partial class showmessage : System.Web.UI.Page
{
SqlOperate sqloperate = new SqlOperate();
SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["constr"]);
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string sqlstr = "select * from tb_Wuliu";
this.dlDataBind(sqlstr, "tb_Wuliu", "id");
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
this.dlInfoBind();
}
protected void lnkbtnOne_Click(object sender, EventArgs e)
{
this.labPage.Text = "1";
this.dlInfoBind();
}
protected void lnkbtnUp_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) - 1);
this.dlInfoBind();
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
this.labPage.Text = Convert.ToString(Convert.ToInt32(this.labPage.Text) + 1);
this.dlInfoBind();
}
protected void lnkbtnBack_Click(object sender, EventArgs e)
{
this.labPage.Text = this.labBackPage.Text;
this.dlInfoBind();
}
public void dlDataBind(string sqlstr, string table, string dkf)
{
int curpage = Convert.ToInt32(this.labPage.Text);
PagedDataSource ps = new PagedDataSource();
sqlconn.Open();
SqlDataAdapter MyAdapter = new SqlDataAdapter(sqlstr, sqlconn);
DataSet ds = new DataSet();
MyAdapter.Fill(ds, table);
ps.DataSource = ds.Tables[table].DefaultView;
ps.AllowPaging = true; //是否可以分页
ps.PageSize = 5; //显示的数量
ps.CurrentPageIndex = curpage - 1; //取得当前页的页码
this.lnkbtnUp.Enabled = true;
this.lnkbtnNext.Enabled = true;
this.lnkbtnBack.Enabled = true;
this.lnkbtnOne.Enabled = true;
if (curpage == 1)
{
this.lnkbtnOne.Enabled = false;//不显示第一页按钮
this.lnkbtnUp.Enabled = false;//不显示上一页按钮
}
if (curpage == ps.PageCount)
{
this.lnkbtnNext.Enabled = false;//不显示下一页
this.lnkbtnBack.Enabled = false;//不显示最后一页
}
this.labBackPage.Text = Convert.ToString(ps.PageCount);
this.dlInfo.DataSource = ps;
this.dlInfo.DataKeyField = dkf;
this.dlInfo.DataBind();
}
public void dlInfoBind()
{
String sqlstr = "select * from tb_Wuliu where UID='" + this.Request["Price"].ToString() + "'and where='" + this.Request["CompanyName"].ToString() + "'and where='"+ this.Request["Linkman"].ToString() +"'and where='"+ this.Request["Tel"].ToString() +"'";
//this.SQLDataRead
}
}
帮我看看编程思想有没有出错?
谢谢!