Monday 16 March 2009

Implement datetime (and other) sorting in ASP.NET gridview

We need some code to load data into the table, then we use the following functions (also add the gridView_Sorting function to handle the OnSorting event of the grid, in the gridview definition in the .aspx file (OnSorting="gridView_Sorting"), same for OnPageIndexChanging event: OnPageIndexChanging="gridView_PageIndexChanging").


   1:  static SortDirection lastSortDirection = SortDirection.Ascending;
   2:  static DataTable roadmapTable;
   3:   
   4:  static string ConvertSortDirectionToSql(SortDirection sortDirection)
   5:  {
   6:      string m_SortDirection = String.Empty;
   7:   
   8:      switch (sortDirection)
   9:      {
  10:      case SortDirection.Ascending:
  11:          m_SortDirection = "ASC";
  12:          break;
  13:   
  14:      case SortDirection.Descending:
  15:          m_SortDirection = "DESC";
  16:          break;
  17:      }
  18:   
  19:      return m_SortDirection;
  20:  }
  21:   
  22:  protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
  23:  {
  24:      roadmapGridView.PageIndex = e.NewPageIndex;
  25:      roadmapGridView.DataBind();
  26:  }
  27:   
  28:  protected void gridView_Sorting(object sender, GridViewSortEventArgs e)
  29:  {
  30:      if (roadmapTable == null)
  31:      {
  32:          return;
  33:      }
  34:   
  35:      lastSortDirection = lastSortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending;
  36:   
  37:      DataView m_DataView = new DataView(roadmapTable);
  38:      m_DataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(lastSortDirection);
  39:      roadmapGridView.DataSource = m_DataView;
  40:      roadmapGridView.DataBind();
  41:  }

Wednesday 4 March 2009

Speed up internet explorer

0. Start IE without addons

Go to Start > All Programs > Accessories > System Tools > Internet Explorer (No Add-ons)

1. Disable the Phishing Filter

The Phishing Filter in IE7 is another area for performance improvement. If you mainly visit sites you trust and have used a lot, you can consider disabling the Phishing Filter in IE7.

  1. In the IE7 Tools menu, select Phishing Filter.
  2. In the submenu select Turn Off Automatic Website Checking.

2. Disable sounds in webpages, under options - advanced - multimedia

3. Disable RSS feed updates - under options - content - feeds

4. Increase max simultaneous connections - I am experimenting with 32 [Edit: max possible is 16 decimal...)

  1. Start the Registry Editor. From the Windows Start menu, select Run. In the Run box, type regedit and click OK.
  2. In the Registry Editor, locate the following key:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\ CurrentVersion\Internet Settings
  3. With the key selected, open the Edit menu, click New and then select DWORD Value.
  4. In the name field for the new value, type MaxConnectionsPer1_0Server.
  5. Create another new DWORD Value and name it MaxConnectionsPerServer.
  6. Now right-click the new entries one-by-one, and select Modify in the popup menu.
  7. Enter the value for the maximum number of connections. By default Hexadecimal entry is selected, so if you type a value of 10 for these new DWORD values you will have a maximum of 16 downloads at the same time.
  8. Close the Registry Editor. Select Exit from the File menu.
  9. Finally reboot your computer and you’re ready to maximize your internet bandwidth usage by downloading multiple files at a time!

5. Limit reserved bandwidth to 0

  1. Open the Run option in the Start menu.
  2. Type gpedit.msc and click OK.
  3. Open the tree as shown in the image (Computer Configuration->Administrative Templates->Network->QoS Packet Scheduler).
  4. In the right-hand panel, double-click the Limit reservable bandwidth option.
  5. Next, change the option from Not Configured to Enabled.
  6. the Bandwidth Limit (%) value, enter zero (0).
  7. Click the OK button.
6. force IE7's menu bar to the Top

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\WebBrowser]
"ITBar7Position"=dword:00000001

undo the change:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\WebBrowser]
"ITBar7Position"=-

7. Hide IE search box

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\InfoDelivery\Restrictions]
"NoSearchBox"=dword:00000001

and undo this

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\InfoDelivery\Restrictions]
"NoSearchBox"=dword:00000000


8. TCP IP Buffers

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]"ForwardBufferMemory"=dword:00024a00
"NumForwardPackets"=dword:0000024a
"MaxForwardBufferMemory"=dword:00024a00
"MaxNumForwardPackets"=dword:0000024a

from http://www.msfn.org/board/lofiversion/index.php/t90257.html