browse by category or date

Today one colleague of mine asking me for tips on improving the DataTable.Select() performance. Apparently she has a data table which contains tens of thousands of records which some of the rows need to be processed together.

This particular question left me scratching my head. The only thing that I can suggest were:

  1. Make sure when populating the data table from the database, the data are already sorted
  2. Make sure the filter parameter of the Select() method is selecting by integer data

Come to think of it, I don’t really know how actually the Select() method is done. Is it using Binary Search, Linear Search, Interpolation Seach or any other search method that I never come across with.

If the case is when the data was fetched from database already in order of an ID, let say CustomerID and the DataTable.Select() is using “CustomerID=1001”, is there any way to optimize this further?

I’ll get back to you when I found the answer. Or maybe you have the answer?

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Printing from a Web programmer perspective is a quite tricky task. Because what we really able to control is on the server side, while the printing is done on the client side.

Unless you create some sort of cool Java applet or custom COM control to help you interface with the printer, you will stuck with Javascript’s Window.print() function.

For those who are stuck without the cool Java applet or the super cool COM control, hopefully this article will help you.

Let’s assume you have the following GridView in your aspx page:

<asp:gridview id="gvCustomersGridView"
        datasourceid="CustomersSource" 
        autogeneratecolumns="true"
        emptydatatext="No data available." 
        allowpaging="true" 
        runat="server">
</asp>

To make this GridView printable, you need to share the clientID to your Javascript printing function. You could either do it by:

  1. previewing the page, copy the ID of the table generated and put it into a variable inside Javascript
  2. Or, you can create a protected variable and put the classic ASP <%= VarName %> inside Javascript

Next, we need to create the print button and the Javascript code to handle the printing.

function Print()
{
	var grid_ID = 'gvCustomersGridView'; //assuming that this is the generated ID
	var grid_obj = document.getElementById(grid_ID);
	if (grid_obj != null)
	{
		var new_window = window.open('print.html'); //print.html is just a dummy page with no content in it.
		new_window.document.write(grid_obj.outerHTML);
		new_window.print();
		new_window.close();
	}
}

You could also comment out the print() and close(), this way user will have a ‘print preview’ and has the chance to set margin, header/footer of the print out.

I hope you find it useful 🙂

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

http://ocw.mit.edu/index.html

I am impressed with the vast availability of information that available here. I recommend this site for those who are hunger with Information.

I wonder when my univ follow the steps to provide the lecture notes/tutorials/assignments to everyone. But would that defeat the purpose of people paying such a huge amount of money to pursue their degree? *grin*

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant: