Cool MSDN ASP.NET 2.0 GridView Control Article

Dino Esposito has published a great article on customizing the ASP.NET 2.0 GridView control, and shows how you can use it to look like the Hotmail inbox:

One thing he doesn't cover, but which is pretty darn cool, is that you can wrap it within an <atlas:updatepanel> and add some additional Atlas Control Toolbox controls to the page and have it be completely Ajax and cross-platform too (which is pretty sweet).

You can read the article here.

Hope this helps,

Scott

P.S. Scott Mitchell is writing 35+ step-by-step articles on databinding scenarios with ASP.NET 2.0 that is really going to rock.  He builds a DAL and then a Business Layer with the first two articles, and then spends the remainder showing off pretty much every common scenario you can think of against them (master/details, master/details/details, inline editing, sorting, paging, deleting, insertion, hierarchical, optimistic concurrency, scoped transactions, etc, etc).  I just reviewed the first 10 this past weekend and they are awesome.  We'll get them published on the web in the next few weeks.

34 Comments

  • Just wanted to say... awesome work guys!! :)



    Keep crankin'!!!

  • Weren't you also busy creating such articles on your blog?



    Grz, Kris.

  • Hi Kris,



    I was -- and got two big ones done, but then got too busy at work (I unfortunately write blog posts simply as a side hobby &lt;g&gt;).



    I ended up working with Scott Mitchell, though, to flesh out all the articles I had been hoping to-do. He has done a really, really awesome job with them so I think you'll like them a lot.



    Hope this helps,



    Scott

  • Thanks Scott,



    Its really helpful when you have some working samples to play with rather than just reading through the instructions (text) and do it yourself.



    Regarding Scott Mitchell's Data tutorials...I'm so looking forward to it!



    Thanks &amp; best regards,



    Raj

  • This is all great but when you want to use GridView in some advanced way like dynamic tree Grids just don't fit. I'm not saying GridView is bad control. I believe it can be used in some good purposes but most of them are too simple.

  • Het Scott, Will it cover how to embed ascx controls that require 2-way data-binding? we're looking at separating common functionality into ascx but need some guidance around the best data-binding techniques.

  • Scott,



    Would you mind posting Scott Mitchell articles' URLs?

  • Just looking for this,Its really helpful.



    Thank you sooo much

  • Thanks to Scott &amp; Scott =),



    one question thought. Is it better to use GridView built in ASP.NET 2.0 callback feature or leave it turned off and use ATLAS framework instead?



    thanks

  • thanks scott,



    its really helpful and simple too.



    josanoop



  • Hi Scott,

    Do Scott Mitchell's articles cover custom DAL creation, or is it all using the designer and drag and drop? I would love to see a good article that uses a more general DAL approach.

  • Hi DT,



    Scott's articles show how to build a business class layer that would work against pretty much any DAL. All of the databinding articles then go against this business layer.



    This means you can swap in your own DAL implementation, and the articles are all still totally relevant.



    Hope this helps,



    Scott

  • Oh Man,,Looking forward Scott M's article.



    Hope thats going to be a gr8 tutorial for building a efeective Business Layer and DAL.



    Thanks a lot for the info.

  • Hi Cowgar,



    I would probabably recommend using an Atlas updatepanel for the GridView -- since that will give you the most flexibility.



    Hope this helps,



    Scott

  • Keep the great content coming! I am eating it up, (and using it too).

  • Cant Wait, When they will be available. With inline editing it will be great if it shows how to do insert new records with Gridview.

    (with reference to Scott Mitchell articles)

    regards



    Khuzema

  • I found a error in the server control.

    e.g

    The selected rows only support 3 property:font-bold,backcolor and forecolor.It is not enough.

    I updated this control and made it to support all sub-properties of SelectedRow.But only BorderStyle property does not run.

    On the other hand , I added a new property which named CheckBoxText. The property sets or retrieves the checkbox Text of headerrow.

    It is so good.

    Thanks Dino and Scott.

  • Good Stuff, helped me with a task last week.

  • This is really good stuff. One question on extending the GridView control, the new checkbox column isn't added to the Columns collection, any ideas on how to get it there?

  • Hi Josh,

    If you want to program in a fully-qualified type-safe way inside expressions you can. The Eval() function is just a short-cut to allow you to do it latebound as well.

    Alternatively you could write something like this:



    Hope this helps,

    Scott

  • Thanks Scott, I am aware of that syntax, but it is a mess from a designer's perspective. It also involves extra casting on every bound item of the row. If you have 10 bound columns, you'd be performing 10 casts. I do prefer this syntax though: (Container.DataItem as MyObject).MyProperty since it saves a couple of keystrokes. But the main problem is that it's just still too many keystrokes and far less elegant looking than the old ASP with the With block. I don't fully understand the code below yet, but it just seems like if this code is autogenerated, then there should be a way to declaratively pass the type information into the parser/build process to automatically perform the casting/conversion step. The real beauty would be being able to just type ".&lt;TAB&gt;" in the IDE and get the strongly-typed intellisense. &nbsp;Well...I can dream right? :-) I tried to dig into the Page and Control builder providers with Reflector to understand how this works, but didn't get very far yet. public void @__DataBind__control15(object sender, System.EventArgs e) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.Web.UI.IDataItemContainer Container; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;System.Web.UI.DataBoundLiteralControl target; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;target = ((System.Web.UI.DataBoundLiteralControl)(sender)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Container = ((System.Web.UI.IDataItemContainer)(target.BindingContainer)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;target.SetDataBoundString(0, System.Convert.ToString(Container.DataItem, System.Globalization.CultureInfo.CurrentCulture)); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}

  • I only thing that i don't know is that when you

    extend control like in hotgrid then intellisense in not available inside &lt;column&gt; tag.

    Any idea to fix that

  • Hi Sandeep,

    Can you provide more information about how you are declaring your columns? You should have intellisense within them.

    Thanks,

    Scott

  • Hi Scott,
    I am working on the grid view in asp.net. It's realy great. But to edit each line item, the user needs to click the edit button and then the line gets activated. What should I do if I want all the items to be activated based on my selection criteria?

  • Scott, I'm trying to find those step-by-step articles that you said S. Mitchell was going to publish. Can't seem to find them anywhere and do not see a link to them here...did they ever get published?

    Thanks!
    Randy

  • Hi Randy,

    Yep -- these tutorials have been posted (the first 27 of 40 of them) here: http://www.asp.net/learn/dataaccess/default.aspx?tabid=63

    Thanks,

    Scott

  • Nevermind..I found them.

  • hi scott,

    did you try how to control the width of each column in this control? I found the width setting for each columns in this control did not work.

    gary

  • Hi Gary,

    Unfortunately it has been several months since I last tried this - so am not sure if I played with the width. But you should be able to control it directly using the GridView control.

    Hope this helps,

    Scott

  • Hello Gary,

    Same problem here. You have all these width properties for control-style/item-style/header/footer, but they just don't work. I see them back in HTML code, so the problem is in the browser???

  • Hi Eric, The problem you are having is not releated to SortingAndPagingCallbacks. Its a problem with the GridView itself. Periodically it fails to maintain the viewstate of the DataKeys array... Very annoying!!

  • Hi man...

    Thanks for this crucial informations for me...it was a perfect match for my necessity

  • I want info about Updating in gridview in Asp.net 2.0.

  • I am not sure if this new GridView extension useful. If you click on the checkbox of the header and navigate to the second page, the checkbox in the header is still checked but none of the items is checked. This is not even close to Hotmail feature. If the author want to have a sample, he need to make sure it works when it is published.

Comments have been disabled for this content.