Ticket T267409
Visible to All Users

GridView - How to bind it with a Stored Procedure in Server Mode

created 10 years ago (modified 10 years ago)

Hi, do you have an exemple where I can use a MVC Grid View with Stored Procedure  where I can pass as a parameter the filter and pagination information.

I found and example but it looks like you retrieve all the data and after that it apply filter and pagination.

I mean this example. This is using a stored procedure but is retrieving all the data.

C#
public ActionResult SupportGridPartial() { StoredProcedureEntities context = new StoredProcedureEntities(); var model = context.SelectSupportTeam(); return PartialView("SupportGridPartial", model); }

Thanks

Answers approved by DevExpress Support

created 10 years ago (modified 6 years ago)

Hello,

Please refer to the How to bind MVC GridView Extension with Entity Framework in a server mode  help article illustrating this scenario.

Updated
Another solution alternative to the use of Entity Framework is to implement a custom binding as it is illustrated in the Advanced Custom Binding demo. You can review details in this help topic: Custom Data Binding - Overview
Let me know if you need further assistance.

    Show previous comments (1)
    Alessandro (DevExpress Support) 10 years ago

      Hi,

      Thank you for your clarification. In this scenario, we suggest the following solution for large data management in a custom manner (e.g., via stored procedures):
      GridView - Custom Data Binding (Advanced) - this solution allows you to implement all data operations manually.
      See also: T267537: GridView - Update data when page change.

        I saw this article before, but the problem that I am dealing with is when I try to overrida the static IQueryable Model we don't know how to get all the current grid information (current page, page size, filter, etc) in order to pass this information to de SP  This is exactly my question. Can you get me some advide in order to do this.
        I am looking something like this.
        static IQueryable Model { get { return
              Page = grid.currentpage;
              filters[] = grid.filters;
              data = MySP (page, filteres, etc)
        }

        Alessandro (DevExpress Support) 10 years ago

          Hi,

          Please take a moment to look at the GetDataAdvanced method in the Advanced Custom Data Binding - ASP.NET MVC Extensions - Grid View Demo. It has all the required information. You can find a similar method (GetData) in the E4394 - How to implement a simple custom binding scenario for GridView code example. Should you need further clarification, feel free to ask. I will be happy to help you.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.