views:

76

answers:

2

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn't work. What am i doing wrong?

 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();
}
+1  A: 

Hard to say with the little info you gave but are any of the parameters strings? If so you need to get quotes in there.

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

Brian Spencer
You're right. But it still didn't fix my problem for some reason.
Eric
A: 

The GridView1 datasource IS (still) bound to SDSIncidentNotes isn't it?

CMH