Is it possible to have an editable and "pageable" GridView using the MVCToolkit? I have thought about this and I'm not sure how to achieve paging and entering in edit mode. I have methods in the model that return a specific page but I'm not sure how to properly
bind the data to the GridView, as the GridView normally has a datasource (like SqlDataSource) that can position the current index somewhere in the result set. But with MVC, I'm not sure how I can do this without writing my own code to display the page links.
As for the editing part, how can I send the new data to the controller? So if anyone could help me with this I would really appreciate it.
So from what I understood controls that require postbacks do not work in MVC. So I'm guessing I should rethink my UI to use some helper controls or something like a repeater and simulate the editing (open up a form) and paging (have some next/previous buttons
that allow retrieval of the next/previous batch).
Paging is easy, and I generally do querystring paging...
/customers/list/?page=5&perPage=20
The GridView (except for basic rendering) will not work with ASP.NET MVC because of their dependence on ViewState & PostBack.
Editable grids are possible, but you have to do it manually. This is arguably the same size of code as you would write with templated GridViews anyway, but I tend to not like editable grids. I generally place an edit link on the row and utilize a redirect/popup/or
ajax-style floating panel to allow me to edit the record in question.
Paging is easy, and I generally do querystring paging...
/customers/list/?page=5&perPage=20
The GridView (except for basic rendering) will not work with ASP.NET MVC because of their dependence on ViewState & PostBack.
Editable grids are possible, but you have to do it manually. This is arguably the same size of code as you would write with templated GridViews anyway, but I tend to not like editable grids. I generally place an edit link on the row and utilize a redirect/popup/or
ajax-style floating panel to allow me to edit the record in question.
I have actually done the paging stuff on another page so that won't be a problem.
Thanks for the idea with the floating panel though. I think that's a good solution for me because I wanted to have a nice rich UI and the ModalPopup AJAX control from the control toolkit should do the the job.
If you're talking about ASP.NET Ajax Control Toolkit, then I'm afraid you can't use it. The client script library works, but the controls rely on ScriptManager, which requires a global form runat="server" tag.
I've used a prototype/scriptaculous dialog and it works quite well. It's here: http://snippets.dzone.com/posts/show/3411
If you're talking about ASP.NET Ajax Control Toolkit, then I'm afraid you can't use it. The client script library works, but the controls rely on ScriptManager, which requires a global form runat="server" tag.
I've used a prototype/scriptaculous dialog and it works quite well. It's here: http://snippets.dzone.com/posts/show/3411
One question about that dialog: how can you actually tell it what to do when you click OK?
Since the dialog itself exists on the page (as a hidden div or user control, whatever).. then you can call any javascript function that exists on the page.
In the page that I used this dialog on, when the user clicks the okay button it calls a function and passes some values from the dialog. The page handles the rest.
Since the dialog itself exists on the page (as a hidden div or user control, whatever).. then you can call any javascript function that exists on the page.
In the page that I used this dialog on, when the user clicks the okay button it calls a function and passes some values from the dialog. The page handles the rest.
Thanks, I got it to work eventually. The bad news is I'll have to handle all the AJAX an UpdatePanel would do. But oh well, I guess you can't have it all :P
anacrisan
Member
6 Points
54 Posts
MVC GridView
Feb 07, 2008 07:25 PM|LINK
asp mvc gridview
Fredrik N
All-Star
29674 Points
5334 Posts
MVP
Re: MVC GridView
Feb 07, 2008 07:50 PM|LINK
Take a look at the following posts about using Server Control with the MVC Framework: http://forums.asp.net/t/1216834.aspx
MVP, ASPInsider, WCF RIA Services Insider
My Blog
anacrisan
Member
6 Points
54 Posts
Re: MVC GridView
Feb 07, 2008 08:11 PM|LINK
subdigital
Contributor
2105 Points
445 Posts
ASPInsiders
Re: MVC GridView
Feb 07, 2008 08:21 PM|LINK
Paging is easy, and I generally do querystring paging...
/customers/list/?page=5&perPage=20
The GridView (except for basic rendering) will not work with ASP.NET MVC because of their dependence on ViewState & PostBack.
Editable grids are possible, but you have to do it manually. This is arguably the same size of code as you would write with templated GridViews anyway, but I tend to not like editable grids. I generally place an edit link on the row and utilize a redirect/popup/or ajax-style floating panel to allow me to edit the record in question.
http://www.flux88.com
ASP.NET MVP
Certified ScrumMaster
ASPInsider
MCSD
anacrisan
Member
6 Points
54 Posts
Re: MVC GridView
Feb 07, 2008 08:41 PM|LINK
I have actually done the paging stuff on another page so that won't be a problem.
Thanks for the idea with the floating panel though. I think that's a good solution for me because I wanted to have a nice rich UI and the ModalPopup AJAX control from the control toolkit should do the the job.
subdigital
Contributor
2105 Points
445 Posts
ASPInsiders
Re: MVC GridView
Feb 07, 2008 08:57 PM|LINK
If you're talking about ASP.NET Ajax Control Toolkit, then I'm afraid you can't use it. The client script library works, but the controls rely on ScriptManager, which requires a global form runat="server" tag.
I've used a prototype/scriptaculous dialog and it works quite well. It's here: http://snippets.dzone.com/posts/show/3411
http://www.flux88.com
ASP.NET MVP
Certified ScrumMaster
ASPInsider
MCSD
anacrisan
Member
6 Points
54 Posts
Re: MVC GridView
Feb 08, 2008 06:22 AM|LINK
One question about that dialog: how can you actually tell it what to do when you click OK?
subdigital
Contributor
2105 Points
445 Posts
ASPInsiders
Re: MVC GridView
Feb 08, 2008 01:45 PM|LINK
Since the dialog itself exists on the page (as a hidden div or user control, whatever).. then you can call any javascript function that exists on the page.
In the page that I used this dialog on, when the user clicks the okay button it calls a function and passes some values from the dialog. The page handles the rest.
http://www.flux88.com
ASP.NET MVP
Certified ScrumMaster
ASPInsider
MCSD
anacrisan
Member
6 Points
54 Posts
Re: MVC GridView
Feb 08, 2008 07:23 PM|LINK
subdigital
Contributor
2105 Points
445 Posts
ASPInsiders
Re: MVC GridView
Feb 08, 2008 07:51 PM|LINK
<form action="/cart/add" method="post" onsubmit="hijack(this); return false"> <%= product.Name %> <input type="hidden" name="id" value='<%= product.Id %>' /> <input type="submit" value="add to cart" /> </form> <script type="text/javascript"> function hijack(form) { var url = form.action + "/?partial"; $ajax(url, { method: form.method, values: $(form).serialize(), dataType: "html", success: update_cart, failure: function(err) { alert(err); } }); } function update_cart(new_html) { $("#cart").html(new_html); } </script>Then in your action, check for ?partial and render a user control directly, rather than the whole page.
http://www.flux88.com
ASP.NET MVP
Certified ScrumMaster
ASPInsider
MCSD