Aaron Goldenthal

Sometimes ASP.NET is Rocket Science

Creating Custom Data Source Parameters

I’m a fan of using the data source controls to simplify data access.  While there’s a reasonable set of Parameters that come with the framework, it’s easy to quickly get to a point where you want functionality that doesn’t automatically come from one of these parameters.  You can always use the Parameter and update the value programmatically, but you can end up with a lot of logic repeated in various Inserting/Updating/Deleting events.  Luckily, creating a custom data source Param... [More]

Creating a Data Control Field – The CounterField

I’ve created a lot of GridViews to display a lot of data.  In many cases they’re simply displaying tabular data and they include one column with a counter cell, typically created with markup like: 1: <asp:TemplateField HeaderText="#"> 2: <ItemTemplate><%# Container.DataItemIndex + 1 %></ItemTemplate> 3: </asp:TemplateField> While this is not overly complicated, rather than create a field like this yet anot... [More]

Manually Databinding a GridView

One of the questions I see frequently on the ASP.NET forums is how to deal with exceptions like The GridView 'GridView1' fired event RowEditing which wasn't handled. The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. The GridView 'GridView1' fired event Sorting which wasn't handled. The GridView 'GridView1' fired event RowDeleting which wasn't handled. when manually databinding a GridView.  When I say manually databinding I mean not using a data source co... [More]

ASP.NET Databinding Bind() Method Dissected

I was thinking about a question on the asp.net forums recently and while doing a little research I learned a few things about how the databinding Bind() method really works, and a few of the limitations. The Bind() methods performs two functions: Extract values during databinding to populate properties of a control (done via the same method used by the Eval() method) Extract values from controls (e.g. to perform insert/update operations) I’ve set up a quick example to illustrate ho... [More]