【发布时间】:2011-05-24 11:56:06
【问题描述】:
在 ObjectDataSource 中,我们有一个名为 SelectMethod 和 TypeName 的方法,我们可以在其中指定一个从中选择数据的方法。
但是 SqlDataSource 中指定数据选择方法的等效方法是什么。如果没有这样的方法,我该如何指定一个方法来选择像 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;
}
【问题讨论】:
标签: asp.net objectdatasource sqldatasource