Skip to content

Manas Bhardwaj's Stream Posts

Get the visitor IP Address

The following snippet shows how to retrieve the IP Address of visitor of your website. Usually, the Request object contains the IP Address in the HTTP_X_FORWARDED_FOR key, but sometimes the ISP provider overrides it to make it null. In that case, you can use REMOTE_ADDR.


//Get the client IP Address
string LstrIPAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(LstrIPAddress))
{
	LstrIPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}

Visual Studio Multi Targeting Support

This time Microsoft is ready to battle with all guns up. In the past posts we have discussed the new features of Microsoft Visual Studio 2008 (aka Orcas). One of the big changes they are coming up with this release of Visual Studio is Multi Targeting Support.So, the first question arises into the mind is ‘What is Multi Targeting Support?’

Till the release of Visual Studio 2005, every release targeted a particular version of .Net. Like VS 2002 was for .Net 1.0, VS 2003 was for .Net 1.1 and VS 2005 for .Net 2.0 and later on supported .Net 3.0. VS 2008 by default targets .NET 3.5-but you can now select which .NET version you wish to target your code for at anytime-while creating the project or even during the development. Obviously, if you’re using a feature that an earlier version of .NET doesn’t support and you try to build using that platform, you will get an error. So what is .NET 3.5 anyway? This version is actually a stack built on the new features from .NET 3.0 and beyond-including things like the ASP.NET Ajax Framework and others (which we will discuss shortly). Full support for the core .NET 3.0 functionality is built in. That is, you can now develop WPF and WF apps in both design and source mode without requiring to install add-ons. A large number of project templates also allow you greater flexibility in choosing how you wish to develop and deploy your application-for instance, when creating a WPF application you can select whether to create a normal WPF application for Windows, an XBAP Browser Application or a Custom WPF Control library.

Download Information for Microsoft Visual Studio 2008

Oh!!! If you have got this page by searching for pirated, warez or whatever weird stuffs than I must say that these surf engine giants still have to go a long way to build a proper one. Well, we are not here to discuss about that. We are here to get the early look on Microsoft Visual Studio 2008.The next version of Visual Studio, Microsoft® Visual Studio® 2008 (formerly known as, Microsoft Visual Studio code name “Orcas”), will provide an industry-leading developer experience for Windows Vista, the 2007 Microsoft Office system, and the Web. In addition, it will continue in the Microsoft tradition of development language innovation.Click here to download the Beta 1 version for MS Visual Studio 2008.

Datagridview with filtering capability

Introduction

The Microsoft Windows Forms Datagridview provided with the MS Visual Studio 2005 has got a lot new and good features which were missing in the datagrid control provided in the earlier versions of MS .Net. But still, many times the developers or I should say the functional need of the application require the filtering capabilities.

In this article, I am gonna explain the method by which we can add the filtering capabilities in the Datagridview header itself.

To just start with and summarize, it can be entirely customized through an xml file and decided to which of columns, the filtering capability is to be provided.

Unlike most of the filtering grids available, it allows you to apply filter on more than one filter at a time and in that too, you can select multiple values in a column. Thus extending the feature for searching/filtering or we should say minimizing the desired view of data to the bare minimum level.

DataGridView_1

DataGridView_2

Using the code

FilterDataGridView is a fully customizable user control. As far as the developer’s point of view is concerned. He will not have to make a single line of code change in his code and yet he can achieve the filtering capability. J

As many of the times, we don’t want to give the filtering capability to all the columns that why FilterDataGridView reads the name of the columns from an xml file which have to be enabled for the filtering.

That means what all one developer has to do is to provide an xml file with the name of the columns to be filtered.

Below, I have mentioned what all steps would need to be taken if you want to replace the old Datagridview with the FilterDataGridView.

  1. Add a reference to the FilteredGridViewControl.dll in your project and also add it to your toolbar.
  2. Drag the FilteredGridView from your toolbar to the window form as you do with any other control.
  3. Add FilterGridView.xml to your application. In the compile property, set the Copy to Output folder option.

This xml should look like this:


<?xml version=”1.0″ encoding=”utf-8″ ?>
<ColumnsToBeFiltered>
	<ColumnName>Branch</ColumnName>
	<ColumnName>City</ColumnName>
</ColumnsToBeFiltered>

You can specify as many columns here which are to be filtered.

And here we go, all is set. Wasn’t that simple?

How it works?

With FilteredGridView, when you right click on a header of a column which is there in the list of Columns to be filtered, it will list all the distinct rows. Now you can select any of the row it your grid will automatically be filtered with that value. FilteredGridView supports applying multiple filters on a single column. That means you can apply as many filters on a column and at the same time you can narrow the data by putting filters on other columns data too.

Assumptions

This version of FilterGridView only works when bound with a Data Source.

Download FilteredGridViewControl Code

Download FilteredGridViewControl