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.OleDb;
using System.Data.SqlClient;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strWhere = "Goods_danwei='集团公司' and Goods_hpmingc like '%设备名称%'";
string[] Str1 = new string[] { "Goods", strWhere };
int Count = GetRecordCount.Int_Count(Str1);
this.AspNetPager1.AlwaysShow = true;
this.AspNetPager1.PageSize = 2;
this.AspNetPager1.RecordCount = Count;
}
datalistbind();
}
private void datalistbind() {
string strWhere = "select * from Goods where Goods_danwei='集团公司' and Goods_hpmingc like '%设备名称%'";
SqlConnection sqlconn = CAN.SqlCon();
sqlconn.Open();
SqlDataAdapter dr = new SqlDataAdapter(strWhere, sqlconn);
DataSet ds = new DataSet();
dr.Fill(ds, AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, "Goods");
this.DataList1.DataSource = ds.Tables["Goods"];
this.DataList1.DataBind();
} protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
this.AspNetPager1.CurrentPageIndex = e.NewPageIndex;
this.datalistbind();
}
protected void LinkButton_xuanze_Click(object sender, EventArgs e) {
int index = ((DataListItem)((LinkButton)sender).NamingContainer).ItemIndex;
Label Label_bianhao = DataList1.Items[index].FindControl("Label_bianhao") as Label;
Label Label_shebeimingc = DataList1.Items[index].FindControl("Label_shebeimingc") as Label;
Label Label_shebeixinghao = DataList1.Items[index].FindControl("Label_shebeixinghao") as Label;
Label Label_shuliang = DataList1.Items[index].FindControl("Label_shuliang") as Label;
//获取用户选择的参数
Label Label_jiage = DataList1.Items[index].FindControl("Label_jiage") as Label;
Label Label_danwei = DataList1.Items[index].FindControl("Label_danwei") as Label;
Label Label_changjia = DataList1.Items[index].FindControl("Label_changjia") as Label;
this.Label1.Text = Label_bianhao.Text;
this.Text_Names.Text = Label_shebeimingc.Text;
this.Text_Xinghao.Text = Label_shebeixinghao.Text;
//this.Text_Count.Text = Label_shuliang.Text;
//传递到用户文本框内。减少输入内容
this.Text_SDanwei.Text = Label_danwei.Text;
this.Text_Jiage.Text = Label_jiage.Text;
this.Text_Changjia.Text = Label_changjia.Text;
}
}
http://www.cnblogs.com/charles2008/archive/2008/02/01/1061396.html
去看看这个