Assiging parameters to sqldatasource

后端 未结 2 767
我在风中等你
我在风中等你 2021-01-25 16:01

I\'m trying to get data from SQL Server and use it in a formview, but the formview control won\'t get any data from the datasource.

(The datasource gets parameter on pag

2条回答
  •  广开言路
    2021-01-25 16:34

    You have two problems:

    1. first you don't need to add the parameter again - it's already defined in your markup
    2. you don't have to use a @ in your parameter name - just the name will do.

    So use this code instead:

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlDataSource1.SelectParameters["idd"].DefaultValue = "077763554";
        FormView1.DataBind();
    }
    

    That should do the trick - set the .DefaultValue on the existing parameter, and use the idd parameter name, as defined in your markup ()

提交回复
热议问题