Results 1 to 9 of 9

Thread: GridView behaviour in MVC

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    243

    Lightbulb GridView behaviour in MVC

    Hi, I'm working on MVC2 based web solution where it have HTMLHelpers to render various kinds of controls over the view. But in the ASP Web Form based solutions there is one of the good control GridView which facilitates user with numerous kinds of things in addition to display the records i.e. add/delete/edit the record, paging and so on. Is this possible in MVC2 or MVC3? or is there any alternative that facilitate some behavior not same but like this with most required things within same location.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: GridView behaviour in MVC

    The GridView is an ASP.NET server control. Server controls get processed by ASP.NET and replaced with the appropriate HTML. In MVC, there are no server controls. It's up to you to generate the appropriate HTML. You can write your own methods to output the exact same HTML code as a GridView if you want, but it's up to you to do it.

    You may want to consider using a jQuery grid instead of doing it all in HTML yourself.

    http://www.trirand.com/blog/
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Re: GridView behaviour in MVC

    yep, you got to let go with the things webforms spoiled you with.

    ideally you want to build your own (it's just a table of records with paging for the most cases anyhow)

    You do have a few other options though (Those I know from the top of my head, just google it)

    MvcContrib Grid
    Telerik
    jQuery Grid


  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: GridView behaviour in MVC

    It's worth noting that the new MVC3 (currently at RC2) includes a WebGrid class that can be used, via a helper method, to build what is essentially the equivalent of a WebForms GridView. There is also jqGrid, which is a free jQuery plugin that provides a very functional grid that is easy to use in an MVC app.
    Last edited by jmcilhinney; Dec 21st, 2010 at 07:04 AM. Reason: Changed DataGrid to GridView
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Re: GridView behaviour in MVC

    Quote Originally Posted by jmcilhinney View Post
    It's worth noting that the new MVC3 (currently at RC2) includes a WebGrid class that can be used, via a helper method, to build what is essentially the equivalent of a WebForms DataGrid.
    Cool. Just started out with MVC3 and did not notice that.


  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Posts
    243

    Lightbulb Re: GridView behaviour in MVC

    Quote Originally Posted by jmcilhinney View Post
    It's worth noting that the new MVC3 (currently at RC2) includes a WebGrid class that can be used, via a helper method, to build what is essentially the equivalent of a WebForms GridView. There is also jqGrid, which is a free jQuery plugin that provides a very functional grid that is easy to use in an MVC app.
    Hi, Thank you jmcilhinney, thats greate......I'll go through WebGrid. Have you any good link containing discussion about this helper method to grasp this quickly.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: GridView behaviour in MVC

    Quote Originally Posted by jivangoyal View Post
    Hi, Thank you jmcilhinney, thats greate......I'll go through WebGrid. Have you any good link containing discussion about this helper method to grasp this quickly.
    Unfortunately there isn't a lot around at the moment. Everything I found was for MVC3 beta and some things have changed a little in the RC. I just searched, read what I could and experimented a bit. I also opened the relevant assembly in .NET Reflector to get a clear idea of exactly what functionality was available.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    Hyperactive Member Krokonoster's Avatar
    Join Date
    Jan 2010
    Location
    Cape Town
    Posts
    448

    Re: GridView behaviour in MVC

    Quote Originally Posted by jmcilhinney View Post
    I just searched, read what I could and experimented a bit. I also opened the relevant assembly in .NET Reflector to get a clear idea of exactly what functionality was available.
    Prodding around in the MVC3 Source code also helps. (Though it seems only MVC 3 Beta source code are available.)
    What I like to do is add the source code to my project, and reference that project instead of Mvc dll's. Rather not do that with the MVC3 site I'm building now though. Not sure what changed between Beta and RC2


  9. #9
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Re: GridView behaviour in MVC

    The best thing about MVC3 is RAZOR engine support, its so much cleaner than WebForms engine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width