Search code examples
asp.netsql-server-2008formview

Updating formview in ASP.net


net.I am designing with help of data views in Visual Studio 2010.GridView and DetailsView run with no issues.In FormView as I am trying to develop a edit template with following code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
        onselecting="SqlDataSource1_Selecting" SelectCommand="SELECT * FROM [student]"
        UpdateCommand="Update student set Id=@Id, Name=@Name, City=@City, Marks=@Marks where Id=@Id" >
        </asp:SqlDataSource>

I am getting an error as follows:

'ASP.default_aspx' does not contain a definition for 'SqlDataSource1_Selecting' and no extension method 'SqlDataSource1_Selecting' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)

How can I solve it ?


Solution

  • It's because you defined

      onselecting="SqlDataSource1_Selecting"
    

    but probably in the code behind there is no function with the right signature