What is the right combination to use Paging and styling in MVC? - asp.net-mvc-3

I may not be finding the best way to ask this, but I'm learning MVC by trying to build a small website. This is supposed to be a shopping website. Here I am on the part of displaying items on the page. I came through webgrid, but its displaying items in tabular form. Should I learn the tricks of tables like those in html? Because I have heard they can be modified to give any view?
Or can there be other alternatives to webgrid? I really like its Paging feature. I don't think I'm good enough right now to code for that. I have tried some googling and found jqgrid but that also seems to be good for tabular representation of data. I have been trying with this webgrid thing from last night and its really not coming together all good. What else can be the option? I mean something abstract enough to provide me good looks of a shopping website's product page, when I can provide a List of products(the model) from controller to the view? Then what?
Update: Basically I wanna know what part am I missing? Modifying Table to create good views? using webgrid properly? Or am I using the webgrid wrongly? something else should be used in this scene?

You can take a look at this simple of example of how to use Twitter Bootsrap to style a WebGrid: WebMatrix WebGrid – Re-Working the Pager.
You can also check out the Twitter Bootstrap site for examples of other ways this can be used to transform tabular data.

Related

Apply Webgrid Pagination to a table

My question is simple. MVC3 has a Webgrid Helper which can be used for paging.
Is there a way to use this helper in a table instead of using the webgrid?
Please advise me in this.
The Pager helper needs a WebGrid to work. If you do not want to use the WebGrid, you can create your own paging links. This article explains how, although it is based on the Web Pages framework and shows how to use paragraphs instead of tables: http://www.mikesdotnetting.com/Article/150/Web-Pages-Efficient-Paging-Without-The-WebGrid
However, if you want to display your results in a table, I don't know why you don't use the WebGrid. It renders a table.

Is it better to use ajax pager or plain post back?

I'm creating a pager for grid data. Basically, I can do it in two ways: when user clicks on a page number, load grid data by using ajax call, or, post back to server (GET or POST) and use query string parameters (or POST variables) to know which page to display. With both methods, sorting of grid items must be persisted.
What is better considering performance and SEO and why?
-- UPDATE --
I need pros and cons for both approaches. I know this is somewhat discussion rather than question, but I need your experiences.
Also, when using ajax, it is not only SEO that I'm wondering about. Will browser's back button behave as expected?
Why not do both.
Have the grid load with SEO friendly anchor GET links then implement some JavaScript to convert them to AJAX calls.
People without JavaScipt (like spiders) can then still navigate around while fancy people will get the enhanced AJAX experience.
With AJAX you can alter history and make the back button work as expected.
Your grids are loaded via AJAX? and you are worried that SEs won't pick them up?
What you can do to get your content indexed is to:
use segmented URLS like CodeIgniter and WordPress instead of query strings. SEs will (supposedly) see them as subfolders.
Instead of loading everything in AJAX, grid data can also be represented as tabular data. What you can do is to load the tabular format for the static page, then with JS, you can replace the table with your grid.
say for example i want to load sports stats, mysite.com/sports/stats should give me tabular data when JS is off, and if i had JS, that data is replaced with the grid.

Getting a value from an MVC 3 Razor RadioButton list

I'm coming from a WebForms environment. When I wanted values from a radiobutton, the form simply got ajax reposted or I got it thru javascript.
I've searched the web, but can't seem to find an equivalent for MVC 3 Razor.
I'm not posting the form, so I can't use the FormCollection object in the ActionResult.
I simply want to get the value of which option in the RadioButton is checked when a user checks one of them.
I assume I would do this thru an Action method in a Controller once a user checks one of the values.
Note also, that this radiobutton list is in a partial view and is available to the entire website (because it is in my _Layout.cshtml view).
Can someone please help me out with what I think should be a simple task?
You need to use javascript. See this post. MVC does not have the concept of an Auto-Postback like in Webforms. This is an optimization in the page loading time (no self-managed viewstate). This means you need to manage the statefulness of controls yourself.
In short, if you're not posting (or "getting") the form then the value won't be available in the controller...more specifically, neither the controller nor it's actions will be called at all.
If you're trying to do something strictly UI related, then you may want to consider jQuery.
If you're trying to do some sort of model validation inside of the view, you may want to reconsider your approach and usage of the MVC pattern.

Using almost same view for editing and viewing

So my question is about handling both editing and viewing document data in same view. Basically, I have a view that can view document data. It has necessary fields and can show text information for user. How can I, guys, edit this document using this one view?
So seems like I need to pass some flag that indicates "editing" or "viewing" mode and show edit textboxes or just text.
Any techniques, methods to achieve this? Could you, guys, advice me something? Any blog posts, articles, manuals will be very appreciated.
Thanks in advance guys!
P.S.: it is ASP .NET MVC3 application (with Razor view engine).
I usually accomplish this using two differant actions (details and edit). You would decorate your actions using AcceptVerbs. POST vs. GET in this case. You can create a single 'partial view' that is returned by both actions. Its behavior (readonly / editable) will be dictated by the action that returns the view.
There is a very straight forward tutorial covering just this here:
CRUD
Reusing Views (Partial View)

Updating data with information received from the view (Grails)

I am writing a Grails app and I have a quick question about the best way to do something. My controller has 2 lists of data, both of which are displayed on the view in separate HTML tables. What I want to do is to have a button that will allow you to move an item from one list to the other. What is the best way to do this?
I have done some research and using some form of AJAX seems to be the general consensus on the best way to do this. Is there any other way? The heart of the problem is that I can't figure out how to update the data contained in the contoller based on the button the user presses in the view.
Thanks
I solved this by just updating the model to reflect the new lists and rerendering the page

Resources