//将数据绑定到GridView控件中
con.Close();//关闭数据库连接
}
public string SubStr(string sString, int nLeng)
{
if (sString.Length <= nLeng) //判断字符串的长度
{
return sString;//返回一个string类型的变量
}
string sNewStr = sString.Substring(0, nLeng);//截取字符串
sNewStr = sNewStr + "...";//在变量后面加上"...."
return sNewStr; //返回一个string类型的变量
}
3.2.6 设备维护查询模块
点击设备维护查询导航按钮,进入设备维护查询页面,可以选择住户名称,住户状态或者经手人进行分类查询,设备维护界面如图17所示:
图17 设备维护界面
关键代码:
Font-Names="华文新魏" Font-Size="Medium" OnRowDataBound="gvS_RowDataBound" OnPageIndexChanging="gvS_PageIndexChanging" ForeColor="Black" Width="832px" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellSpacing="2" AllowPaging="True" AllowSorting="True" GridLines="None">
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection con = DB.createDB();
OleDbCommand cmd = new OleDbCommand();//声明一个OleDbCommand的 cmd对象,并将其实例化
cmd.Connection = con;
con.Open();
DataSet ds = new DataSet(); //声明一个DataSet的ds对象,并将其实例化
if (this.rbtnyhm.Checked == true)
{
OleDbDataAdapter sda = new OleDbDataAdapter("select * from tb_weihu where name='" + this.txtyhm.Text + "'", con);
sda.Fill(ds, "tb_weihu");
this.gvS.DataSource = ds;
this.gvS.DataBind();//将数据绑定到GridView控件中
}
if (this.rbtnzt.Checked == true)
{
OleDbDataAdapter sda = new OleDbDataAdapter("select * from tb_weihu where state='" + this.ddlzt.SelectedItem.Text.ToString() + "'", con);
sda.Fill(ds, "tb_weihu");
this.gvS.DataSource = ds;
this.gvS.DataBind();//将数据绑定到GridView控件中
}
if (this.rbtnjsr.Checked == true)
{
OleDbDataAdapter sda = new OleDbDataAdapter("select * from tb_weihu where person='" + this.txtjsr.Text.ToString() + "'", con);
sda.Fill(ds, "tb_weihu");
this.gvS.DataSource = ds;
this.gvS.DataBind();//将数据绑定到GridView控件中
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("weixuiguanli.aspx");
}
protected void gvS_RowDataBound(object sender, GridViewRowEventArgs e)
{
上一篇:
毕业论文-基于net的超市管理系统
下一篇:
马原:环境保护与可持续发展论文(word)