小弟最经在做一个简单应用,中间遇到一个常见的问题:
根据客户在TextBox录入值的不同,实时查询,更新GridView中的数据
也就是在TextBox中,
用户输入:23,就按23%模糊查询;
用户输入:23324,就按23324%模糊查询;
应该是比较常见的问题,大家一定遇到过,希望大家可以指点一下!
分不够可以再加,小弟对.Net不是太清楚,诚心求救
就是我页面有一个 textbox,然后还有一个gridview
我想在键入textbox的同时gridview同时更新数据
onkeyup局部刷新gridview
答案:3 悬赏:70
解决时间 2021-11-14 20:42
- 提问者网友:你在我心中是最美
- 2021-11-14 08:07
最佳答案
- 二级知识专家网友:承载所有颓废
- 2021-11-14 09:28
string goodsId = this.txtGoodsID.Text.Trim();
string brandId = this.txtBrandID.Text.Trim();
string goodsName = this.txtGoodsName.Text.Trim();
string brandName = this.txtBrandName.Text.Trim();
string key = edtKey.Text.Trim();
string sesql = "select * from goods";
if ("".Equals(goodsId) && "".Equals(brandId) && "".Equals(goodsName) && "".Equals(brandName) && "".Equals(this.txtMarketPrice.Text) && "".Equals(this.txtSalePrice.Text) && "".Equals(this.txtkstime.Text) && "".Equals(this.txtjstime.Text) && !"".Equals(key))
{
sesql += " Where (goodsId like '%" + key + "%') Or (brandId like '%" + key + "%') Or (brandName like '%" + key + "%') Or (goodsName like '%" + key + "%') Or (marketPrice like '%" + key + "%') Or (salePrice like '%" + key + "%') Or (inputTime like '%" + key + "%')";
}
SqlConnection cn = new SqlConnection("Server=.;DataBase=MyProject;Integrated Security=true;");
SqlCommand cmd = new SqlCommand(sesql, cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
this.gvData.DataSource = dt;
this.gvData.DataBind();
希望能帮到你
string brandId = this.txtBrandID.Text.Trim();
string goodsName = this.txtGoodsName.Text.Trim();
string brandName = this.txtBrandName.Text.Trim();
string key = edtKey.Text.Trim();
string sesql = "select * from goods";
if ("".Equals(goodsId) && "".Equals(brandId) && "".Equals(goodsName) && "".Equals(brandName) && "".Equals(this.txtMarketPrice.Text) && "".Equals(this.txtSalePrice.Text) && "".Equals(this.txtkstime.Text) && "".Equals(this.txtjstime.Text) && !"".Equals(key))
{
sesql += " Where (goodsId like '%" + key + "%') Or (brandId like '%" + key + "%') Or (brandName like '%" + key + "%') Or (goodsName like '%" + key + "%') Or (marketPrice like '%" + key + "%') Or (salePrice like '%" + key + "%') Or (inputTime like '%" + key + "%')";
}
SqlConnection cn = new SqlConnection("Server=.;DataBase=MyProject;Integrated Security=true;");
SqlCommand cmd = new SqlCommand(sesql, cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
this.gvData.DataSource = dt;
this.gvData.DataBind();
希望能帮到你
全部回答
- 1楼网友:错过的是遗憾
- 2021-11-14 11:52
看了半天就是没看出来你遇到了什么问题..
再看看别人怎么说的。
- 2楼网友:哥在撩妹请勿打扰
- 2021-11-14 10:36
需要捕捉键盘事件
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯