急!请教textbox查询多行数据显示的问题 本帖最后由 citydemon1 于 2010-03-31 23:04:28 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string[] content = this.txtBookBarCode.Text.Replace("\r", "").Split('\n'); string strCond = ""; foreach (string s in content) { if(s.Trim() == string.Empty) continue; strCond+= "'"+s.Trim()+"',"; } if(strCond.Length ==0) { RegisterStartupScript("", "<script>alert('物品条形码不能为空')</script>"); return; } strCond = strCond.Substring(0,strCond.Length-1); string sql = "select * from tb_bookInfo where bookBarCode IN("+strCond+")"; DataSet ds = dataOperate.getDataset(sql); if (ds.Tables[0].Rows.Count > 0) { gvBookBorrow.DataSource = ds; gvBookBorrow.DataKeyNames = new string[] { "bookBarCode" }; gvBookBorrow.DataBind(); } else RegisterStartupScript("", "<script>alert('物品条形码错误!')</script>"); gvBookBorrow.DataSource = ds; gvBookBorrow.DataKeyNames = new string[] { "bookBarCode" }; gvBookBorrow.DataBind(); 你这段代码 在循环里面重复执行了! 所以只显示最后数据了楼上代码给出了 gridview 分页 图片上传问题 系统设计文档如何写,提供模版最好(网址,网站) 关于System.Web.HttpContext.Current.User.Identity.Name access中 ,子查询 'n_content' 中 Memo 或 OLE 对象无效. 大型网站开发中的一个问题???? passwordRecovery控件问题 智能建站、个性化空间技术问题 讨论一下做什么网站有前途? session怎么设置绝对时间 请大侠们帮我看看分页问题 谁能帮检查一下这个搜索页哪里出错啊
string strCond = "";
foreach (string s in content)
{
if(s.Trim() == string.Empty) continue;
strCond+= "'"+s.Trim()+"',";
}
if(strCond.Length ==0)
{
RegisterStartupScript("", "<script>alert('物品条形码不能为空')</script>");
return;
} strCond = strCond.Substring(0,strCond.Length-1); string sql = "select * from tb_bookInfo where bookBarCode IN("+strCond+")";
DataSet ds = dataOperate.getDataset(sql);
if (ds.Tables[0].Rows.Count > 0)
{
gvBookBorrow.DataSource = ds;
gvBookBorrow.DataKeyNames = new string[] { "bookBarCode" };
gvBookBorrow.DataBind();
}
else
RegisterStartupScript("", "<script>alert('物品条形码错误!')</script>");
gvBookBorrow.DataKeyNames = new string[] { "bookBarCode" };
gvBookBorrow.DataBind(); 你这段代码 在循环里面重复执行了! 所以只显示最后数据了
楼上代码给出了