Unhandled Exception
A technical blog about asp.net and other geeky things. Follow me <a href="http://twitter.com/davidfowl/">http://twitter.com/davidfowl/</a>
-
Follow me on twitter!
I've finally got sucked into twitter after avoiding it for many months. Check me out:
http://twitter.com/davidfowl/ -
Dynamic ListView LayoutTemplate
There are times when you want to let the user change layout dynamically. You can use css to do this but lets look at what the ListView control offers. To get started with the ListView you need a LayoutTemplate and ItemTemplate.
-
AutoFieldGenerators
In 3.5 SP1 we added new properties to GridView and DetailsView which allows the page developer to change the way AutoGenerateColumns creates its columns. This feature is well know in Dynamic Data, but it is not tied to this technology. Dynamic Data takes advantage of this by looking at the meta data that users set on properties to generate columns.
You too can roll your own IAutoFieldGenerator. Lets look at the interface: -
How <%# Bind %> Works
In my last post I spoke about 2-way databinding and how it can be used to extract values from control properties. How does this all work? Lets take a look at a page with 2-way databinding:
-
Getting your data out of the data controls
After you've created a layout with a data control of your choice and eventually bound them to some datasource, you almost always want to get that data back out of them(and why wouldn't you, its your data). One thing you'll learn about developing asp.net webpages is that its like petting a porcupine (yikes). If you go with the flow, you probably won't get stuck, but the moment you try to go against the grain you end up with a hand full of thorns.
Most of the data controls have events ending in ing and ed e.g. RowUpdating, RowUpdated etc. In most of the event handlers of the ing events it is easy to get the values from the event args. -
Dynamic Sorting with Linq
When trying to implement a Business Logic Layer (i will refer to this as BLL) with linq one thing that is an annoyance is sorting. Lets say you had a BLL that was being used by ObjectDataSource and had a select method that does sorting and paging, then you'd probably be tempted to write something like this:
private IQueryable<Product> SortBy(IQueryable<Product> source, string sortBy) {
DataControls 101 Part 2: Why you should love Datasource controls
I've been scouring the forums recently trying to find problems people encounter when using the data controls. One thing that I found is mostly asked for but is kind of a hidden art:
How do I use the GridView/ListView/DetailsView.... without a Datasource control? (and still get all the fancy features offered).Now I've always know that you can do this but I decided to explore how much is involved in making this stuff to work. This sample shows a GridView using raw Linq queries in C#. Let’s dive into the code:
Markup
<asp:GridView
Data Controls 101
I’ve worked with asp.net a bit at school before I came to Microsoft. Being the “data dev” as you would imagine, I get lots of bugs that have to do with the data (datasource/databound) controls. I also scan the internal and external forums and try to help customers find solutions to their problems. This blog post is the first of a series on common scenarios using data controls, that I call Data Controls 101.
First Post
Hey everyone, my name is David Fowler and I'm new to the ASP.NET team. I've been an intern here in Redmond for the last 2 summers and I’m glad to be back as a FTE (Full Time Employee in microspeak). My responsibilities include all things data related to ASP.NET. This includes things like the Datasource and Databound controls as well as Dynamic Data. I look forward to posting some interesting stuff in the near future!