Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

How Do I Enable Inline GridView Editing?

0 (0 Likes / 0 Dislikes)
  • Embed Video

  • Embed normal player Copy to Clipboard
  • Embed a smaller player Copy to Clipboard
  • Advanced Embedding Options
  • Embed Video With Transcription

  • Embed with transcription beside video Copy to Clipboard
  • Embed with transcription below video Copy to Clipboard
  • Embed transcript

  • Embed transcript in:
    Copy to Clipboard
  • Invite a user to Dotsub
[Microsoft] [] [ Dynamic Data, How do I enable inline GridView editing?] [Scott Hanselman] Hi, this is Scott Hanselman, and this is how do I get inline editing working in Dynamic Data. In our first video we created a very simple scaffolding site using the Northwind database. I added a Northwind data context, and when I hit play and start debugging I get a list of my tables. You see I've got products here. I can click on products. We notice our URL says Products/List. If I hover over edit, notice in the status bar there it says Products/Edit. If I click on edit I come to a details page that is filled out where I can make changes to my product. I can hit update or cancel. How do I get inline editing in Dynamic Data? Well, it comes down to routing If you remember in the previous video, when we look at our global.asax our default route looked like this. It took a table name like Products and an action where that action is one of list, details, edit, or insert, where edit takes the action of update as well. Well, you've also got some commented out routes at the bottom here. Let's switch routes. I'll comment this one out and I'll comment this one in. Rather than taking in {table}/Actions, this one takes in ListDetails, and it handles PageAction.List while the details view is handled here. So in this case the list action and the details action are both being handled by the same page—ListDetails. ListDetails exists in here in our page templates. So where are edit and insert? Well, they're right here because they're being handled all in one place inline on the ListDetails grid. Let's take a look at this in action. Now we'll click on Products. Notice that our URL has changed. We're looking at ListDetails but, for the most part, it looks pretty much the same. Let's see if it's, in fact, changed. Let's hit edit. There we go. Now I've got inline editing. This is done in the kind of standard way that inline editing is done, and I'll show you the code-behind, but it's a little simpler than you're used to seeing with I can make a change, hit update, everything has been handled by the ListDetails. I haven't actually left so there isn't the need for that edit action. It's all handled in one place. I make a new. I make it here, and then it automatically appears elsewhere in the list, everything, again, being handled by the ListDetails page. So how is this happening behind the scenes? Well, let's take a look at ListDetails. Remember that these are templates—this isn't necessarily code generation as it is templating via this meta model that we have. Our Dynamic data manager on the page. If we scroll own we see our GridView. The GridView is set to auto-generate columns so we didn't need to set anything in the GridView. Ordinarily we would have bound columns. In a future video we'll see how that gets replaced with a dynamic field and with dynamic controls. GridView doesn't actually list out the columns yet. It's auto-generating everything. We'll see in a future video when we get to plug in our own custom columns, custom details, display names, formatting, as well as the dynamic control in the forms view and the list view, and how to add dynamic fields in the grid and details view, but for now, in this particular view, the GridView exists here. Details exist here and everything else is auto-generated. But don't worry, I'll show you how you can customize everything. You won't be forced to be stuck with just the auto-generated stuff. So now, how do I have inline editing for one table but perhaps a more complicated details view for another table? How can I change this on a table by table basis? Well that's where the power of routing comes in. Here we're taking any table and we're handling the things in the ListDetails view, but, if I want to, I can put the first route back in. If you're familiar with MVC you'll notice that this routing comes from MVC and—even though in this case we're using Web Forms— and routes are evaluated in order, so here where it says table, what if I just change that to products and then added Table = "Products" So now in this case the products page will get the standard master detail separate edit page while all other tables will get inline editing experience. We'll hit play—some people call it "start debugging" but I like to think of it as a little VCR. You hit products, notice our URL says /Products/List. We hit edit, we get our edit view. Now we're in Products/Edit.aspx. Let's go back to the homepage and look at orders. Orders is still done as a ListDetails page. I can hit edit and I get inline editing. So just by changing the route we've told Dynamic Data enough information to do the right thing and pick different templates, and remember that those templates are coming out of the Page templates folder. We'll see how we can customize those—override them for specific tables in future videos. See you soon. [Microsoft] []

Video Details

Duration: 6 minutes and 23 seconds
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 7
Posted by: neudesicasp on Sep 20, 2013

Now that you have created a site with Edit and Details views, how do you enable inline editing in a GridView control? This video shows you how, and also touches on routing.

Caption and Translate

    Sign In/Register for Dotsub to translate this video.