SQLDatasource parameters

前端 未结 2 1490
遇见更好的自我
遇见更好的自我 2021-01-20 20:07

How can i set sql parameters for an sqlDatasource in the code behind? I am trying like this:

int id=1;
SqlDataSource1.SelectCommand = \"SELECT * FROM categ W         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 20:18

    Make sure you add the select parameters before trying to set their default value.

    i.e.

    SqlDataSourceArticole.SelectParameters.Add("@id", id);
    SqlDataSourceArticole.SelectParameters["id"].DefaultValue = id.ToString();
    

提交回复
热议问题