Australian Story :: Dzung's Anatomy

Tuesday, 13 June 2006

My wife and her family are friends with the Davis family, and Carl (their son) is married to Thau (Dzung's daughter).

View Trace.axd

Sunday, 11 June 2006

Roger has written a Firefox Extension that ASP.NET developers will find very useful.

As I always say, "Anything that saves me extra keystrokes is a good thing!"

PageMethod Testamonial

Monday, 5 June 2006

Fabrice has published my testamonial about how we are using the PageMethods component with our development of an Online Assessment Tool.

ObjectDataSource and Sorting (Part 2)

Thursday, 1 June 2006

Sergio asked if I could post how I solved my problem with sorting and the ObjectDataSource control.

Here's what I did:

First of all, add a parameter to the method that is being called by the ObjectDataSource control that will be used to sort the data.

    <DataObjectMethod(DataObjectMethodType.Select)> _
    Public Shared Function GetTests(ByVal sortExpression As String) As TestInfoCollection
 
        If sortExpression Is Nothing Then
            Throw New ArgumentNullException("sortExpression")
        End If

It's up to you what you do with the value that is passed in. The value comes in looking like the sort bit of SQL. In my case to get things up and running I'm loading my data into a DataTable, then use a DataView to do the sorting for me - not the most efficient way but it works for now. Later on, I might pass the sort criteria down to SQL Server and let it do the sorting for me, but that will require messing with the stored procedures!

It seems like an oversight that there isn't a special attribute to prepend the sortExpression parameter so that the ObjectDataSource recognises it as special - unfortunately it just thinks it's a regular parameter and will add it to the SelectParameters part in the aspx file. You just need to remove it from there and instead make sure the SortParameterName attribute is set instead.

<asp:ObjectDataSource id="odsTests"
runat="server"
TypeName="UniSA.UniSAnet.SmartMark.DataAccess.TestComponent"
SelectMethod="GetTestsForCourse"
SortParameterName="sortExpression">
<SelectParameters>
<asp:QueryStringParameter ConvertEmptyStringToNull="False" Name="courseId" QueryStringField="CourseId" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>

NUnitGenAddIn

Wednesday, 31 May 2006

Here's a Visual Studio.NET add-in for generating NUnit unit tests