In ObjectDataSource we have a method called SelectMethod and TypeName in which we can specify a method to select data from.
But what is the equivalent method in SqlDataSource to speicify a method for data to select from. If there is no such method, how can I specify a method to select data like in ObjectDataSource
<asp:ObjectDataSource ID="ObjEmployees" runat="server"
SelectMethod="GetEmployees" TypeName="AllowPaging.GetData">
</asp:ObjectDataSource>
SqlConnection connection = new SqlConnection("server=NIPUNA-PC\\SQLEXPRESS; database=KTD; Trusted_Connection=yes;");
string commandText = "SELECT * FROM [Emp]";
public DataSet GetEmployees()
{
SqlCommand cmd = new SqlCommand(commandText, connection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
See this: https://web.archive.org/web/20211010104134/https://www.4guysfromrolla.com/articles/112206-1.aspx
the SqlDataSource and ObjectDataSource raise their Selecting events immediately before performing the SQL query or invoking the object method to retrieve data. After the data has been retrieved, the Selected events fires. By creating a Selecting event handler, you can examine and massage the parameters used in selecting data;
You can use these event handlers to specify which method is used by the datasource control.