Kevin Isom
Just a good ol' boy, by-God Virginia-proud and country-sophisticated -- sort of like a John Deere tractor with air conditioning and satellite radio.
-
Hiding a Popup Panel with JavaScript
Had a instance where I needed to close the Popup Control with JavaScript
-
Setting Form Values Automatically with SubSonic
Tedious coding sucks. SubSonic saves lots of time. But I want it to save me more. So I've started working on a method that will fill out the controls for me so I don't have to. It's simple really. I just new() up a the model I will use and pass it to my method along with the UserControl I have my form elements in.
-
Setting the enum from it's name
I've changed this a bit due to some comments
-
Grabbing Data from a GridView on PostBack
Have you ever wanted to grab bulk data on a grid view? It's actually not that hard at all. Set the System.Web.UI.WebControls.GridView.DataKeys Property on the Grid, then on the postback event iterate over the grid like so.
-
SubSonic LoadFromPost
I think SubSonic is simply amazing. It has saved me so much time and effort of writing. One little trick that it's got is the LoadFromPost method the Models inherit from the SubSonic.AbstractRecord<T> class.
-
Update to Ajax control toolkit breaks autocomplete
I recently updated an application to the latest version of the Ajax Control Toolkit and my AutoComplete Extender broke. It was returning the list fine. but in the dropdown the only values showed were undefined. Not cool. But after some research I changed the web service that returns the values to use the new AutoComplete Item
-
Custom Parameter for a DataSource
While using a cookie parameter for an ObjectDataSource I discovered that you get the whole cookie, not the value from a key....So instead of my method getting passed the value, it was getting passed key=value. Needless to say I was a little miffed. But I quickly discovered how easy it is to create my own custom data parameter.
-
SubSonic, ObjectDataSource, Paging, and you!
SubSonic is such a time saver. Fresh out of the box it gives you so much goodness that it makes you wonder how you developed without it. However one feature I find lacking is that it doesn't have a paging method from the get go. However it's easy enough to implement paging with SubSonic.
The trick is you have to created two methods to get the paging to work. The drawback to using the ObjectDataSource for paging is that the GridView doesn't take an output parameter as the record count. So what do you do to take advantage of the SubSonic goodness? First create the select method and the select count in the controller class.
The trick to remember is that the ObjectDataSource passes passes in the count of the items but the paging method exposed by SubSonic expects the actual page number. This means that if your PageSize is 10 changing to the second page the start is 20, but SubSonic expects 2.1: [DataObjectMethod( DataObjectMethodType.Select, false )]
2: public MyCollection FetchAllPaged(int start, int pageLength)
3: {
4: int startIndex;
5: if(start ==0)
6: {
7: startIndex = 1;
8: }
9: else
10: {
11: startIndex = start / pageLength + 1;
12: }
13: MyCollection coll = new MyCollection();
14: Query qry = new Query( My.Schema );
15: qry.PageSize = pageLength;
16: qry.PageIndex = startIndex;
17: coll.LoadAndCloseReader( qry.ExecuteReader() );
18: return coll;
19: }
20: public int FetchAllCount()
21: {
22: Query qry = new Query( My.Schema );
23: return qry.GetCount( My.Columns.MyId );
24: }
1: <asp:GridView ID="TheGrid" runat="server"
2: AllowPaging="True"
3: DataSourceID="MyDataSource"
4: PageSize="10" />
5: <asp:ObjectDataSource ID="MyDataSource" runat="server"
6: SelectMethod="FetchAllPaged"
7: TypeName="MyController"
8: SelectCountMethod="FetchAllCount"
9: StartRowIndexParameterName="start"
10: MaximumRowsParameterName="pageLength"
11: EnablePaging="True"
12: />
-
Sorting a generic list
One of the nice features of System.Collection.Generics.List is it is able to sort on the go with a IComparable, and you can do that simply with an anonomous method
This is simply done like so.