I see what you're trying to achive, and think you still can get around with typed datasource along with SqlParameter and its' filter expessions
<data:ProductsDataSource ID="ProductsDataSource" runat="server" SelectMethod="Find">
<Parameters>
<data:SqlParameter Name="Parameters">
<Filters>
<data:ProductsFilter Column="CategoryID" ControlID="__Page" PropertyName="CategoryID" />
</Filters>
</data:SqlParameter>
<data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
</Parameters>
</data:ProductsDataSource>
Here is how to get ObjectDataSource to work (like you describe, except the objectdagtasource declared on page):
<asp:ObjectDataSource runat="server" ID="ObjectDataSource"
TypeName="MyDal.CustomersSearch"
SelectMethod="GetCustomersByContactName"
EnablePaging="false" SortParameterName="SortBy"
>
<SelectParameters>
<asp:ControlParameter ControlID="__Page" Name="ContactName" PropertyName="WhereClause" />
<asp:Parameter Name="SortBy" Direction="input" />
</SelectParameters>
</asp:ObjectDataSource>
code-behind:
void cmdSearch_Click(object sender, EventArgs e)
{
if (txtContactName.Text != string.Empty)
{
WhereClause = txtContactName.Text;
GridView1.DataBind();
}
}
public string WhereClause
{
get
{
if (ViewState["_whereClause"] != null)
{
return (string)ViewState["_whereClause"];
}
return string.Empty;
}
set
{
ViewState["_whereClause"] = value;
}
}
namespace MyDal
{
public class CustomersSearch
{
public TList<Customers> GetCustomersByContactName(string ContactName, string SortBy)
{
CustomersParameterBuilder searchQuery = new CustomersParameterBuilder();
searchQuery.Append(CustomersColumn.ContactName, string.Format("{0}*", ContactName));
TList<Customers> tlist= DataRepository.CustomersProvider.Find(searchQuery.GetParameters());
tlist.Sort(SortBy);
return tlist;
}
}
}
see if helps
Mike Shatny
--------------------------------------------------------------
Member of the .netTiers team http://www.nettiers.com
--------------------------------------------------------------