Oct 6 2006

Code Geeks, where are you?

Category:Bil@l @ 08:09

Google introduced a new search service called Code-Search, which is best sutied for Code Geeks [:D].

Have a look at it here: http://www.google.com/codesearch

Regards

Tags:

Oct 5 2006

Filter Collection of Objects

Category: ASP.NET 1.x | ASP.NET 2.0 - GeneralBil@l @ 06:04

I have been developing an API for an application of mine at work. The API returns a set of objects in the form of Collections. I needed a way to filter the collection based on some values I provide.

I have passed by this blog post:

http://codebetter.com/blogs/brendan.tompkins/archive/2004/09/02/24116.aspx

Brendan creates something known as CollectionView, that supports both Windows and Web collections.

I took that code, and did some modifications on it:

  1. I removed the IBindingList interface
  2. I removed all methods from the IList and ICollection implementation that might allow change of data in teh input Collection.
  3. I removed the sorting feature

I made the collection a normal collection that takes as input a collection, and then allows the developer to filter data inside.

In addition, I made the CollectionView capable of filtering not only on the direct properties of the classes inside the IList, but also multilevel properties as follows:

Currently, you can filter on simple data-types properties:

public string/int/double (etc ...) PropertyName
{
   get {}
   set {}
}

My CollectionView allows you to do filtering even on:

public Person MyPerson
{
    get {}
    set {}
}

Where Person is a class, so you can filter a collection of objects, where each object might have a property of type another object, i.e. you can filter a collection based on a property in the multilevel properties of the objects in the Collection.

An example illustrates how to use the new ApplyFilter method:

Suppose, a class Person has a property of type Address, where Address is another class that has a property called City as follows:

 

 public class Person
 {
  //members
  private string firstName=null;
  private string lastName=null;
  private Address address = null;
  
  //Public constructor
  public Person(string FirstName,string LastName, Address address)
  {
   this.firstName =FirstName;
   this.lastName=LastName;
   this.address = address;
  }

  #region Properties for member access
  public string FirstName
  {
   get
   {
    return firstName;
   }
   set
   {
    firstName=value;
   }
  }

  public string LastName
  {
   get
   {
    return lastName;
   }
   set
   {
    lastName=value;
   }
  }

  public Address Address
  {
   get
   {
    return this.address;
   }
   set
   {
    this.address=value;
   }
  }

  #endregion
 }
}


 public class Address
 {
  private string city;

  public string City
  {
   get
   {
    return this.city;
   }
   set
   {
    this.city = value;
   }
  }

  public Address(string City)
  {
   this.city = City;
  }
 }

Now you create a collection of Person class as follows:

PersonCollection pCol = new PersonCollection();
Person p1 = new Person("Bilal", "Haidar", new Address("Beirut"));
Person p2 = new Person("Lara", "Keyrouz", new Address("Beirut"));
Person p3 = new Person("Wessam", "Zeidan", new Address("Zahle"));
Person p4 = new Person("Ziad", "Hanna", new Address("Beirut"));
Person p5 = new Person("Alaa", "Said", new Address("Saida"));

Now, you want to get all persons in Beirut, which is a property called City inside object Address, where Address is a property inside Person class, so you can see the hierarchy:

Person
   --------> Address
                       --------> City

What you do is use the new ApplyFilter method as follows:

CollectionView cv = new CollectionView(pCol);
cv.ApplyFilter("Address","City", new Object[] {"Beirut"},FilterOperand.Equals);

The first parameter in the ApplyFilter is the Property, the second is the SubProperty, then an array of objects to provide the data in where to search, then an operand of equals.

You can even search for direct and simple properties as follows:

CollectionView cv = new CollectionView(pCol);
cv.ApplyFilter("FirstName",null, new Object[] {"Bilal"},FilterOperand.Equals);

I have also added a new Filter Option called "InRange", this way, you can search for a set of values as follows:

CollectionView cv = new CollectionView(pCol);
cv.ApplyFilter("FirstName",null, new Object[] {"Bilal", "Wessam"},FilterOperand.InRange);

This way, it will bring you person records whose FirstName are in a set of values (Bilal and Wessam).

The additions are:

  1. Support for multilevel property filter
  2. A new Filter Operan called InRange has been added
  3. Data to be filtered according to has been changed to an array of Objects

You can download the CollectionView.cs file and use it in your applications.

I will be enhancing it with sort option, maybe more Filter Operands too!!

Hope you liked this post!!

Regards

 

Tags: ,

Sep 27 2006

FunctionX Resource

Category:Bil@l @ 11:30

A friend of mine at work found a very interesting website in his process to learn SQL Server, that has many detailed tutorials that helps all those willing to learn C#, VB.NET, ADO.NET, SQL Server, etc ... to get a very detailed and good introduction!!

http://www.functionx.com/

Hope you will like the website!!

Regards

Tags:

Sep 21 2006

Extended GridView Control

Category:Bil@l @ 20:37

Dear all,

I have been receiving a huge amount of emails asking me about the source code of the extended GridView control I published on ASPAlliance.com at this url:

http://aspalliance.com/946

I am really sorry for letting you wait all this time. As you know we had war in my country, and it has been only one week I came back to Lebanon. We have lots of pressure at work and I'm unable to open the GridView control solution to do any fixes or additions.

I kindly ask you to wait on me some time before I will be able to upload the source code with the latest changes!!

I truly appreciate your understanding for the situation!

Best Regards,

Bilal.

Tags:

Aug 30 2006

Silicon Valley Code Camp, October 7th & 8th

Category:Bil@l @ 10:37

CodeCamp at FootHill College. Click Here for Details and Registration

 

For more information, check out the following URL:
http://www.SiliconValley-CodeCamp.com/Home.aspx

Regards

Tags:

Aug 29 2006

UserGroups Listed on Microsoft

Category:Bil@l @ 06:26

It is nice to see my user group listed on the Microsoft website:

http://www.microsoft.com/middleeast/Communities/usergroups.aspx

Check it out!!

Regards

Tags:

Aug 26 2006

xGrid on CodePlex

Category: ASP.NET 2.0 - GeneralBil@l @ 06:23

Hello,

I have decided to place the xGrid on CodePlex because of the huge number of comments and feedback I am receiving every day on the xGrid.

The xGrid needs some enhancements and improvements by adding additional features.

Hope you all will be able to help me out in moving this xGrid to a new stage, where all developers can use it for free with the maximum features available!

Regards

Tags:

Aug 21 2006

Page Properties and SqlDataSource-ObjectDataSource-AccessDataSource

Category: ASP.NET 2.0 - GeneralBil@l @ 13:57

A nice tip given by Stephan Walther in his latest book, ASP.NET 2.0 Unleashed is how to use a page property as a parameter to either Insert, Delete, Update, or Select parameters.

As you know, we have a set of new parameter objects that can be used to supply data to Sql, Object, and Access DataSources. Among which is the ControlParameter.

ControlParameter usually uses a control on the page. Since a Page is also a control, then we can use the Page control as follows

<asp:ControlParameter Name="IPAddress" ControlID="__page"
                PropertyName="IPAddress" />

In this example, you can see that the ControlParamter uses the ControlID as "__page", where __page is the name of the Page control at run time. The propertyName here represents a property that you have created on the page code-behind as:

    Public ReadOnly Property IPAddress() As String
        Get
            Return Request.UserHostAddress
        End Get
    End Property

So, you are able to use the Page property simply as input for the ControlParameter.

Hope this helps,

Regards

Tags:

Aug 16 2006

ASPAlliance Times : An Extended GridView Control

Category:Bil@l @ 12:44

I was so surprised this morning to read the ASPAlliance newsletter and notice that my article was chosen as the featured article for this week.

Not only that, Steven Smith added his "Editor's Comments" all on my new extended control. I haven't seen before the editor's comments on an article but rather on a new third-party control or even new technology.

Here are the comments:

Our featured article this week is really worth a look.  The standard GridVew
is a huge improvement over the DataGrid in ASP.NET 1.x, but in this article,
Bilal looks extends the control with over 10 pages worth of additional
features, covering many of the features that typically require the use of a
third-party control.  Some of the added features include selection based on
row click or doubleclick, filters, row checkboxes, confirm buttons, and sort
images in the header.  The article also does a good job of showing how you
can extend the GridView (or other ASP.NET controls) yourself.  Check it out!

http://aspalliance.com/946

Regards,
Steve

Wow Steve, that is too much for me!! I am very happy to know that I did something cool and good for the community too!!!

Thanks a lot for your support and for ASPAlliance.com!!

Regards

Tags:

Aug 16 2006

Syria wins the War, how?

Category:Bil@l @ 09:57

As a first comment on the war my country had in the last 30 days between Israel and the Hezbollah:

Syria considers itself a winner through Hezbollah how? Syria was able to win more than 5000 job opportunities for its unemployed people in Syria to work in Lebanon in reconstructing the country after Israel, in the name of Attacking the Terrorists, destroyed the entire country.

Isn't this a great prize Israel gave to Syria? 5000 Job Opportunities and even more who knows? Doesn't this serve the purpose of having less pressure on the Syrian government from its people who owe nothing but the food they eat and all the richness of the country are owned by few persons controling everything there? Does this mean that Syria prepared this bloody act on Lebanon together with Israel? Does this mean Iran prepared this brutal act on Lebanon together with Israel? Questions whose answers are very obvious!!

Regards to my beloved country, Lebanon!!

Tags: