【问题标题】:Set Select command in code在代码中设置选择命令
【发布时间】:2009-11-09 15:06:18
【问题描述】:

打开按钮 单击我想设置 Gridview 的选择命令。我这样做,然后对网格进行数据绑定,但它不起作用。我做错了什么?

 protected void bttnView_Click(object sender, EventArgs e)
{
  ImageButton bttnView = (ImageButton)sender;
    String param1 = bttnView.CommandArgument.Split(',')[0];
    String param2 = bttnView.CommandArgument.Split(',')[1];
    String param3 = bttnView.CommandArgument.Split(',')[2];

    SDSIncidentNotes.SelectCommand = "select * from table Where param1 = " + param1 + " and param2 = " + param2+ " and param3 = " + param3 ;


    GridView1.DataBind();
    UpdatePanel2.Update();
}

【问题讨论】:

    标签: c# .net asp.net vb.net visual-studio


    【解决方案1】:

    很难说您提供的信息很少,但是否有任何参数字符串?如果是这样,您需要在其中获取报价。

    SDSIncidentNotes.SelectCommand = "select * from table where param1 = '" + param1 + "' and param2 = '" + param2+ "' and param3 = '" + param3 + "'" ;

    【讨论】:

    • 你是对的。但由于某种原因,它仍然没有解决我的问题。
    【解决方案2】:

    GridView1 数据源(仍然)绑定到 SDSIncidentNotes 不是吗?

    【讨论】:

      猜你喜欢
      • 2019-02-22
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 2011-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-17
      相关资源
      最近更新 更多