Thursday, September 21, 2006

Why SOA?

1. Service oriented
2. Agile development
3. Removes complexity
4. Supplies common programming interface and interoperability protocol
5. Easy up-gradation
6. Lead towards automated business automation
7. Based on XML
8. Web service platform
9. Reusability
10. Loosely coupled
11. Ease in integration process.
12. Able to leverage existing application and infrastructure
13. Less maintenance cost involved.
14. Reduces hardware cost.
15. Leverage existing development skills
16. Faster application development.
17. Eliminate redundant systems and architecture.
18. Reduce project risk
19. Secured.
20. Flexibility

Sunday, September 03, 2006

Brief on SOA:

The buzzword SOA means Service Oriented Architecture. SOA is loosely coupled in nature. It based on SOAP (Simple Object Access Protocol). As per World Wide Web Consortium (W3C) SOA is 'A set of components which can be invoked, and whose interface descriptions can be published and discovered'.

By using SOA architecture it is possible to develop abstract, reusable, relevant, standard, consumable and standardized solutions.

SOA plays major role in enterprise level integration.

Saturday, September 02, 2006

Article: Data Binding and Static Items in List Controls

Abstract:

In this article Kuldeep Deokule shows you how to add static items while implementing data binding on list controls.

Introduction:

ListControl is the abstract class for all list type controls (System.Web.UI.WebControls.ListControl). These list type controls are CheckboxList, DropdownList, Listbox, RadiobuttonList. The properties of the ListControl class allow you to specify the source of the data to populate the list controls. Use the DataSource property to specify the data source to bind to the list controls. Consider the scenario, you’ve a DropdownList control on a web form that is binded to datasource control like SqlDataSource or ObjectDataSource. DropdownList will populate with list of newsletters.

Now, as a good developer you’ve added functionality to select multiple items in DropdownList control by holding control key down. But suppose some user want to receive all newsletters. If you say to user, select all newsletters one by one by holding control key down. This will become very tedious process for any user. User will hate to do this task. So now you want to add one static item “Send All Newsletters” as a top item in the DropdownList. So if user wants to receive all newsletters, user will just select one item. One more design point is on a web page Newsletters DropdownList field is an optional selection for user. So it is impossible to create a DropdownList that doesn’t have a selected item. At least one item in DropdownList control is always selected. So you decided to add one more item in DropdownList control as “Select”. This will be top and default item in DropdownList control.

But due to data binding limitation, “Select” and “Send All Newsletters” list items will be destroyed when you run the web page. Only fetched newsletters from database will be available in DropdownList control. So how to solve this problem?

Solution:
Data source controls make developers life easier but in some case they cannot go beyond bounds specified. It is a limitation of data source controls that they destroy static items created earlier. Most websites need static items in list type controls.

To work out with this problem some developers like to add static items to database directly. But it is not a good idea. These items will unnecessarily reflect in every report related to newsletters table.

Some experienced developers put UNION query in SelectCommand of the data source controls like shown below:

SELECT ‘(Send All Newsletters)’ as AllNewsLetters
UNION
SELECT DISTINCT Newsletters FROM Newsletters

Again above UNION query is not a good idea. By doing this you are adding presentation logic details to data layer, which is not a good programming practice.

It is a weakness of data binding model that you cannot add static items. But static items are required in many cases in list type controls. So what is a good solution to solve above problem? Just take a look at following steps to solve the problem:

1. Add DropdownList control to web form.
2. Do not set any data source control to it through property window or using smart tag.
3. Add Page_Load event in code behind file as show below:

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
'Set up the data binding.
NewsletterList.DataSource = SqlDataSource1
NewsletterList.DataTextField = "newsletter"
NewsletterList.DataValueField = "id"
NewsletterList.DataBind()


'Add following items and select the first item by default.
NewsletterList.Items.Insert(0, "Select")
NewsletterList.Items.Insert(1, "Send All Newsletters")
NewsletterList.SelectedIndex=0
End If
End Sub

Now browse the web page. All static and dynamic items are present in DropdownList control. Insert method with position value add items in DropdownList control at appropriate locations. Code line NewsletterList.SelectedIndex=0 cause to select top item as a default item for DropdownList control. Instead of SqlDataSource control you can also use ObjectDataSource control for data binding purpose. Code will remain same for both data source controls only DataSource attribute will change to respective control name.

AppendDataBoundItems Property in ASP.NET 2.0:

ASP.NET 2.0 exposes AppendDataBoundItems property for all list type controls. This property make this task little easier. If AppendDataBoundItems property is set to true for DropdownList control. Then added static items are not destroyed at the time of page load.
Just take look at following code:

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
'Set up the data binding.

NewsletterList.Items.Add("Select")
NewsletterList.Items.Add("Send All Newsletters")
NewsletterList.AppendDataBoundItems = True
NewsletterList.DataSource = SqlDataSource1
NewsletterList.DataTextField = "newsletter"
NewsletterList.DataValueField = "id"
NewsletterList.DataBind()

NewsletterList.SelectedIndex=0
End If
End Sub



If you set AppendDataBoundItems property to False then all static items will be destroyed. Value of AppendDataBoundItems is stored in view state.
So AppendDataBoundItems will do all magic for us. AppendDataBoundItems is only available in .NET framework 2.0. So for ASP.NET 1.x this solution will not work.

Conclusion:
In this way we can go beyond the limits of data source controls. Above solutions will help you to add static items to data bound list type controls.

Visitor Count: