browse by category or date

Almost losing sleep because of my colleague’s question, I posted the question in .NET Groups where I frequently hang out.

One contributor suggested me to use DataTable.Rows.Find(), especially when we are searching by the Index column of that DataTable. I never heard of this, so I keep it noted as an additional advise to my colleague.

After much thinking, I somehow became doubting that DataTable.Select() is the actual source of the bottleneck. So this morning I asked her to run the profiler to check the performance of her program. The profiler’s result proven my doubt. The bottleneck was caused by multiple calling of Web Services.

All this time I already have a little discomfort with Web Service. I thought the overhead of transmitting data by text XML is too much, especially when you have thousands of records transmitted at an instance. So I spent a little time to googling for opinions that against Web Service (Web Service here refers to those web services that commonly implemented using SOAP). Eventually, I stumbled to this page. I highly recommend it. It’s funny, it’s witty and you might want to use it as an argument when debating against SOAP proponents 🙂

Talking about Profiler, she is using ANTS Profiler. It’s not free 🙂 But you could download the 14-days trial. And of course you can always ask Google for a help.

GD Star Rating
loading...

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:

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?

GD Star Rating
loading...

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 🙂

GD Star Rating
loading...

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: