用拼写查询SQl语句的方法。
1。适配器的SelectCommand语句生成数据集dataSet1,与datagrid绑定。
查询时,根据checkbox被选中的情况,动态生成SelectCommand.text。
例:
string str="Select * from cateoty,report where cateory.cd_cateory=report.cd_cateory";
if(checkBox1.checked) str+=" and cateoty.title="+textbox1.text;
if(checkBox2.checked) str+=" and cateoty.name ="+textbox2.text;
if(checkBox1.checked) str+=" and cateoty.key  ="+textbox3.text;
atp_search.SelectCommand.Text=str;
atp_search.SelectCommand.fill(dataSet1);
datagrid1.DataBind();2.设置datagrid的selectIndexChange事件。
在事件函数里处理传递参数给另一页

解决方案 »

  1.   

    嗬嗬,奇怪了。难道不是
    select * from yourTable where title ='aaa' and author = 'fefe' and name = 'name'
      

  2.   

    用一个存储过程来执行查询!
    .查询时用datagrid显示所有的查询结果(数据库中有表:cateory, report,其中cateory.cd_cateory=report.cd_cateory),怎样使datagrid每次均绑定不同的查询结果?
    每次查询后对datagrid重新绑定!
    如何实现当点击datagrid中任意一行时显示另一页:result.aspx,
    在datagrid中使用按钮列,用select的事件.然后用C#写一个执行windows.open()的javascript脚本就行了!
      

  3.   

    我一般都是拼接sql语句来实现的。
      

  4.   

    用SQL语句来查询,或者先在SQL SERVER上写个相关的存储过程
      

  5.   

    能说得再详细一些么?还是一头雾水阿,我用的是SQL SERVER
      

  6.   

    你要是想使datagrid每次均绑定不同的查询结果时,可以把每次的查询结果都放在一个虚表中啊,适配器对象.Fill(ds,"虚表名");还可以把虚表保存下来用DataView["表名"] = ds;如何实现当点击datagrid中任意一行时显示另一页:result.aspx,你可以加一个隐藏列(主键),每次点击时把这个隐藏列传过去,再根据这个主键找到你要显示的其它列,然后回添就可以了!
      

  7.   

    用sql写存储过程传入你要查询的条件做为参数,
    我们的项目都是这么做的
      

  8.   

    现在问题1已经解决了, 关键是问题2怎样处理呢?怎么样把所选择的这一行的参数传到result.aspx呢?希望高手给与解答
      

  9.   


    在你绑定的DataGrid的ItemDataBound事件中处理,如:private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemIndex > -1)
    {
    e.Item.Attributes.Add("onmouseover","this.setAttribute('e',this.style.backgroundColor);this.style.cursor='hand';this.style.backgroundColor='#dddddd'");
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=this.getAttribute('e');"); e.Item.Attributes.Add("onclick","javascript:window.open('result.aspx?id="+ e.Item.Cells[0].Text +"');" );
    }
    }
      

  10.   

    传递的参数为DataGrid1中第一列的值:
    e.Item.Attributes.Add("onclick","javascript:window.open('result.aspx?id="+ e.Item.Cells[0].Text +"');" );//单击时打开result.aspx,并传递参数id,你可以在result.aspx页中处理传递来的参数如果再搞不定的话,发个短消息给我!!!
      

  11.   

    1.首先判断textBox是否为空;
    2.在1.判断的基础上适当修改sql语句中的where子句,增加或减少几个条件即可OK!