Skip to main content


Showing posts from September, 2010

How to add a static item to a databound dropdownlist

In this post i will show how to add static item to dropdownlist like a dropdown that displays one static item such as "select" while the rest of the items are data bound, then check out the code below: 

Set the AppendDataBoundItems property of the dropdownlist to True, and add in the static list item. Your dropdown will look something like this:

 <asp:DropDownList ID="ddlCountry" runat="server" AppendDataBoundItems="true">             <asp:ListItem Text="Select" Value="-1"></asp:ListItem>         </asp:DropDownList>
check out the complete code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headrunat="ser…

How to use anonymous and Lambda expression in .net

In this post I will discuss how to use anonymous and lambda expression in .net.Imagine we have a simple example in c# that simply add two numbers.
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program {     publicdelegateint Fn(int a, int b);     staticvoid Main(string[] args)     {         Fn add = new Fn(Add);         Console.WriteLine(add(1, 2));     }     publicstaticint Add(int a, int b)     {         return (a + b);     } }
Let’s refactor the delegate instance version of the code to use an anonymous method.What is anonymous method? Anonymous methods are a new language feature in C# 2.0. Anonymous methods allow us to define a code block where a delegate object is acceptable. Let’s convert the above code using anonymous code. Remove the following method from the delegate instance version
publicstaticint Add(int a, int b)         {             return (a + b);         }
And replace following code with
Fn add = new Fn(Add); With this on…

3 Tier Architecture in ASP.NET

In this post i will show how to create 3 -tier architecture in going to technical details,I will describe some details about what is 3 tier architecture and what are the main components of 3 tier architecture.

The three-tier architecture was comes into existence to improve management of code and contents and to improve the performance of the web based applications.There are mainly three layers in three-tier architecture.These are define as follows…

1.  UI(InsertCustomer.aspx): First layer Presentation contains mainly the interface code, and this is shown to user. This code could contain any technology that can be used on the client side like HTML, JavaScript or VBScript etc.

2. Business Logic(CustomerBL.cs) : Second layer is Business Logic which contains all the code of the server-side .This layer have code to interact with database database and to query, manipulate, pass data to user interface and handle any input from the UI as well.

3. DataAccess Layer(CustomerDAL.c…