문제

I have a ListView and i use the SelectMethod of the ListView to populate it. I am looking to apply filters to the data returned from a DropDownList. The problem that i am facing is i cannot DataBind() on this ListView because of the SelectMethod that is uses.

So figure i would change that and DataBind() the whole time instead of using the SelectMethod(Is that better?). Then the problem I face is my method was grabbing [RouteData]. Right now i am grabbing the [RouteData]as a param to my method. Please see below.

   public IQueryable<Product> GetProducts([RouteData] string categoryName, , [RouteData] string brandName, [RouteData] string subCatName)
{
       //Do stuff
}

below is the ListView

   <asp:ListView ID="productList" runat="server"
     DataKeyNames="ProductID"
     ItemType="E_Store_Template.Models.Product"
     SelectMethod="GetProducts">
       // do stuff 
</asp:ListView>

How can I use DataBind() and still grab the [RouteData] from URL? Or do i have to use QueryString to do this?

도움이 되었습니까?

해결책

I was able to grab the route data by using the code below. This allowed me to grab that data and use Databind() instead of having to use the selectmethod to get this data.

Convert.ToString(Page.RouteData.Values["categoryName"]);



Convert.ToInt32(Page.RouteData.Values["scID"]);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top