It's because you defined
onselecting="SqlDataSource1_Selecting"
but probably in the code behind there is no function with the right signature
Domanda
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 ?
Soluzione
It's because you defined
onselecting="SqlDataSource1_Selecting"
but probably in the code behind there is no function with the right signature
Altri suggerimenti
Error:
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?)
Your 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>
Problem With the code
onselecting="SqlDataSource1_Selecting" there is no extension for this available
Updated:
Your Web.config defines an OleDb connection string (for the OleDb engine) that uses the SQL Server OleDb provider to connect to SQL Server through OleDb.
Your code then passes that connection string to a SqlConnection, which connects directly to SQL Server using the SQL native client and uses a completely different connection string.
You should change Web.config to use System.Data.SqlClient and its connection string format. (this is more efficient than OleDb)