我有一个ListView,我使用ListView的SelectMethod来填充它。我希望将过滤器应用于从DropDownList返回的数据。我面临的问题是我不能在这个ListView上使用DataBind(),因为它使用的是SelectMethod。
因此,我会改变这一点,并一直使用DataBind(),而不是使用SelectMethod(这样更好吗?)。然后我面临的问题是我的方法是抓取[RouteData]。现在,我正在抓取[RouteData]作为我的方法的参数。请看下面的内容。
public IQueryable<Product> GetProducts([RouteData] string categoryName, , [RouteData] string brandName, [RouteData] string subCatName)
{
//Do stuff
}下面是ListView
<asp:ListView ID="productList" runat="server"
DataKeyNames="ProductID"
ItemType="E_Store_Template.Models.Product"
SelectMethod="GetProducts">
// do stuff
</asp:ListView>如何在使用DataBind()的同时仍能从URL抓取[RouteData]?或者我必须使用QueryString才能做到这一点?
发布于 2013-03-09 04:20:17
通过使用下面的代码,我能够获取路由数据。这允许我获取数据并使用Databind(),而不必使用selectmethod来获取数据。
Convert.ToString(Page.RouteData.Values["categoryName"]);
Convert.ToInt32(Page.RouteData.Values["scID"]);https://stackoverflow.com/questions/15250692
复制相似问题