SQLDatasource parameters

前端 未结 2 1488
遇见更好的自我
遇见更好的自我 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();
    
    0 讨论(0)
  • 2021-01-20 20:35

    You can update the value by:

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

    Using the default value can work in this case.

    HTH.

    0 讨论(0)
提交回复
热议问题