// ----------------------------------------------------------------------------
// Copyright (C) 2004 – 2005 Yasin Alladin
// All rights reserved. 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE
// ----------------------------------------------------------------------------
/// <summary>
/// File Name: AlladinDataGrid.cs
///<Author> Yasin Alladin</Author>
///<Date> 16-Feb-2005</Date>
///<Description>
/// This custom datagrid webcontrol will provide out of the box functionalities with full state management
/// by just setting properties at designtime, runtime or web config file and extended properties
/// of a datacolumn for achieving following features:
///1.  Expliciltly fire an edit, delete or pagerediect events.
///2.  Captions for Edit, Update, Cancel & Delete buttons can be either text or graphic.
///3.  On double click of any row, editcommand or pageredirect event of the row will be performed.
///4.  On single click of any row, selectcommand will be performed on the client end,
///    thus saving the roundtrip to server.
///5.  Sorting of the columns ASC/DESC on corresponding clicks on the column header.
///6.  Paging of the datagrid.
///7.  Maintaining State Across Pages Or A Page For Checked Records.
///8.  Complete Inline Edit & Fully Editable Support based on the datatype of the datacolumn
///    i.e. Add Textboxs with thier Maxlength, date control, dropdownlist, elipse button,
///    requiredfieldvalidator if not null column, rangevalidators for numeric columns
///    and must more....
///9.  Makes A Particular Row or Column ReadOnly conditionally & unconditionaly.
///10. Making A Particular Cell As ServerSide Link Button or An Email link button.
///11. etc....
/// </Description>
/// </summary>

using System;
using System.ComponentModel;
using System.Configuration;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace Alladin.Controls.DataGrid
{
 /// <summary>
 /// This custom datagrid webcontrol will provide out of the box functionalities with full viewstate management
 /// by just setting properties at designtime, runtime or web config file and extended properties
 /// of a datacolumn for achieving following features:
 ///1.  Expliciltly fire an edit, delete or pagerediect command events from an external control
 ///    i.e. HTML Button.
 ///2.  Captions for Edit, Update, Cancel & Delete buttons can be either text or graphic.
 ///3.  On double click of any row, editcommand or pageredirect event of the row will be performed.
 ///4.  On single click of any row, selectcommand will be performed on the client end,
 ///    thus saving the roundtrip to server.
 ///5.  Sorting of the columns ASC/DESC on corresponding clicks on the column header.
 ///6.  Paging of the datagrid.
 ///7.  Maintaining State Across Pages Or A Page For Checked Records.
 ///8.  Complete Inline Edit & Fully Editable Support based on the datatype of the datacolumn
 ///    i.e. Add Textboxs with thier Maxlength, date control, dropdownlist, elipse button,
 ///    requiredfieldvalidator if not null column, rangevalidators for numeric columns
 ///    and must more....
 ///9.  Makes A Particular Row or Column ReadOnly conditionally & unconditionaly.
 ///10. Making A Particular Cell As ServerSide Link Button or An Email link button.
 ///11. etc....
 /// </summary>
 [DefaultProperty("Text"),
 ToolboxData("<{0}:AlladinDataGrid runat=server></{0}:AlladinDataGrid>")]
 public sealed class AlladinDataGrid: System.Web.UI.WebControls.DataGrid
 {
  #region Enum Declaration
  /// <summary>
  /// Defined enumerations for the different types of edits.
  /// </summary>
  public enum edittype
   {
    /// <summary>
    /// Fires AlladinPageRedirect Event.
    /// </summary>
    PageRedirect=0,
    /// <summary>
    /// Allows Normal Inline Edit Of The DataGrid.
    /// </summary>
    InLine=1
   };
  /// <summary>
  /// Defined enumeration for the different type of delete message.
  /// </summary>
  public enum deletetype
   {
    /// <summary>
    /// Displays a Delete Message Before Performing A PostBack.
    /// </summary>
    DeleteWithConfirmation=0,
    /// <summary>
    /// Does Not Displays a Delete Message Before Performing A PostBack.
    /// </summary>
    DeleteWithOutConfirmation=1
   };
  /// <summary>
  /// Defined Enumeration For The Different Type Of Cancel Message.
  /// </summary>
  public enum canceltype
   {
    /// <summary>
    /// Displays a Cancel Message Before Performing A PostBack.
    /// </summary>
    CancelWithConfirmation=0,
    /// <summary>
    /// Does Not Displays a Cancel Message Before Performing A PostBack.
    /// </summary>
    CancelWithOutConfirmation=1
   };
  /// <summary>
  /// Defined Enumeration For The Different Type Of LinkColumnType
  /// i.e. Edit or Delete Position In The DataGrid.
  /// </summary>
  public enum linkcolumntype
   {
    /// <summary>
    /// First Visible Column On The DataGrid.
    /// </summary>
    FirstColumn=0,
    /// <summary>
    /// Second Visible Column On The DataGrid.
    /// </summary>
    SecondColumn=1
   };
  /// <summary>
  /// Defined Enumeration For Different Type Edit & Delete Link i.e. Normal hyper Link or Image Button.
  /// </summary>
  public enum captiontype
   {
    /// <summary>
    /// LinkCommandColumn Display Type Will Be Normal Hyper Link.
    /// </summary>
    Text,
    /// <summary>
    /// LinkCommandColumn Display Type Will Be Image Button.
    /// </summary>
    Graphics
   };
  /// <summary>
  /// Defined Enumeration For Different Type CheckBoxState.
  /// </summary>
  public enum checkboxstate
   {
    /// <summary>
    /// Do Not Persist or Add The CheckedRecords To a DataSet.
    /// </summary>
    NoState=0,
    /// <summary>
    /// Persist or Add CheckedRecords To A Dataset For All The Checked Record Across Pages.
    /// </summary>
    StateAcrossPages=1,
    /// <summary>
    /// Persist or Add CheckedRecords To A Dataset For A Given Page.
    /// </summary>
    StateForSinglePage
   }
  /// <summary>
  /// Defines The Status of The TextBox Editable or ReadOnly.
  /// </summary>
  public enum textboxtype
  {
   /// <summary>
   /// Textbox Will Be On Editable.
   /// </summary>
   ReadOnly = 0,
   /// <summary>
   /// Textbox Will Be Editable.
   /// </summary>
   Editable = 1
  }
  /// <summary>
  /// Defines The Status For Iterating CheckBoxes.
  /// </summary>
  private enum GridRowType
  {
   /// <summary>
   /// All CheckBoxes Will Be Iterated.
   /// </summary>
   AllRows,
   /// <summary>
   /// Only Specify CheckBoxes Will Be Iterated.
   /// </summary>
   SingleRow
  };
  /// <summary>
  /// Defined Enumeration For DataColumns Extented Properties Which Are Mapped With Item Cells Controls etc..
  /// </summary>
  public enum alladindatagridcelltype
   {
    /// <summary>
    /// TextBoxControl or DropDownControl Width.
    /// </summary>
    EditableControlWidth,
    /// <summary>
    /// DropDownList Text Field Which Should Map To The Datacolumn.
    /// </summary>
    DropDownListDataTextField,
    /// <summary>
    /// DropDownList Value Field Which Should Map To The Datacolumn.
    /// </summary>
    DropDownListDataValueField,
    /// <summary>
    /// DropDownList Text i.e. SELECT Which is Displayed On Screen On The First Column Of The DropDownList.
    /// </summary>
    DropDownListDefaultTextField,
    /// <summary>
    /// DropDownList Delimeter Is Required To Be Set If More Than One DropDownList Appear In A Item Cell.
    /// </summary>
    DropDownMultipleControlDelimeter,
    /// <summary>
    /// DropDownList Relation Names To be Specified With DropDownMultipleControlDelimeter As The Delimeter.
    /// </summary>    
    DropDownMultipleControlRelationName,
    /// <summary>
    /// RequiredFieldValidator Message i.e. Required Which Is Added Automatically When A Not Null Field Control Is Added To The Grid.
    /// </summary>
    DefaultRequiredFieldMessage,
    /// <summary>
    /// If A Control Is To Be Visible To Be Rendered On The Client Or No.
    /// </summary>
    Visibility,
    /// <summary>
    /// If A ElipseButton Control i.e. TextBox And HTMLButton Is Added InStead Of Normal Controls Mostly Used If Data Has To be Copied From A Popup Window.
    /// </summary>
    ElipseButton,
    /// <summary>
    /// RangeValidator Message i.e. Invalid Data Which Is Added Automatically When A Numeric i.e. Int, Decimal etc.. Control Is Added To The Grid.
    /// </summary>
    DefaultRangeValidatorMessage,
    /// <summary>
    /// RangeValidator Min Value For Decimal DataTypes Which Is Added Automatically When A Numeric i.e. Int, Decimal etc.. Control Is Added To The Grid.
    /// </summary>
    DefaultRangeValidatorDecimalMinValue,
    /// <summary>
    /// RangeValidator Max Value For Decimal DataTypes Which Is Added Automatically When A Numeric i.e. Int, Decimal etc.. Control Is Added To The Grid.
    /// </summary>
    DefaultRangeValidatorDecimalMaxValue,
    /// <summary>
    /// RangeValidator Min Value For Integer DataTypes Which Is Added Automatically When A Numeric i.e. Int, Decimal etc.. Control Is Added To The Grid.
    /// </summary>
    DefaultRangeValidatorIntegerMinValue,
    /// <summary>
    /// RangeValidator Max Value For Integer DataTypes Which Is Added Automatically When A Numeric i.e. Int, Decimal etc.. Control Is Added To The Grid.
    /// </summary>
    DefaultRangeValidatorIntegerMaxValue,
    /// <summary>
    /// Explicit RequiredFieldValidator Control.
    /// </summary>
    RequiredFieldValidator,
    /// <summary>
    /// Explicit RequiredFieldValidator Control Error Message.
    /// </summary>
    RequiredFieldValidatorMessage,
    /// <summary>
    /// Explicit RangeValidator Control.
    /// </summary>
    RangeValidator,
    /// <summary>
    /// Explicit RangeValidator Control Error Message.
    /// </summary>
    RangeValidatorMessage,
    /// <summary>
    /// Explicit RangeValidator Control Validation Type i.e. Currency, Date, Integer, Double & String in proper case.
    /// </summary>
    RangeValidatorType,
    /// <summary>
    /// Explicit RangeValidator Control Min Value.
    /// </summary>
    RangeValidatorMinValue,
    /// <summary>
    /// Explicit RangeValidator Control Max Value.
    /// </summary>
    RangeValidatorMaxValue,
    /// <summary>
    /// Explicit RegularExpressionValidator Control.
    /// </summary>
    RegularExpressionValidator,
    /// <summary>
    /// Explicit RegularExpressionValidator Control Error Message.
    /// </summary>
    RegularExpressionValidatorMessage,
    /// <summary>
    /// Explicit RegularExpressionValidator Control's Validation Expression.
    /// </summary>
    RegularExpressionValidatorValidationExpression,
    /// <summary>
    /// Explicit CustomFieldValidator Control.
    /// </summary>
    CustomFieldValidator,
    /// <summary>
    /// Explicit CustomFieldValidator Control Error Message.
    /// </summary>
    CustomFieldValidatorMessage,
    /// <summary>
    /// Explicit CustomFieldValidator Control's  ClientValidationFunction Name.
    /// </summary>
    CustomFieldValidatorClientValidationFunction,
    /// <summary>
    /// Explicit Email Hyper Link Column.
    /// </summary>
    EmailHyperLink,
    /// <summary>
    /// Explicit Email Column Name if The Link Column Is Not Suppose To Be Used For Email.
    /// </summary>
    EmailColumnName,
    /// <summary>
    /// Explicit Link Button Control.
    /// </summary>
    LinkButton,
    /// <summary>
    /// Explicit Boolean ColumnName Used To Make TextBox Control ReadOnly Based On The Value Of The Column.
    /// </summary>
    ReadOnlyColumnName
   };
  #endregion
  #region Delegate Declaration 
  /// <summary>
  /// Defined delegate is used for datagridbinding event
  /// </summary>
  public delegate void DataGridDataBinding();
  /// <summary>
  /// Defined delegate is used for datagridexception event
  /// </summary>
  public delegate void DataGridException(object source, Exception exception);
  /// <summary>
  /// Defined delegate is used for datagrid row event
  /// </summary>
  public delegate void DataGridRow(object source, DataSet dataset);
  /// <summary>
  /// Defined delegate is used for datagrid pageredirect event
  /// </summary>
  public delegate void DataGridPageRedirect(object source, DataSet dataset, string CommandName);
  #endregion
  #region Constant Declaration Region
   /// <summary>
   /// Defines The Sort Desc Direction.
   /// </summary>
   private const string SORTDESC = " DESC";
   /// <summary>
   /// Defines The Sort Asc Direction.
   /// </summary>
   private const string SORTASC = " ASC";
   /// <summary>
   /// Defines The Hidden Control Name For Sort Direction
   /// </summary>
   private const string HIDDENSORTDIRECTIONID  =  "hidSortDirection";
   /// <summary>
   /// Defines The Hidden Control Name Sort Expressions
   /// </summary>
   private const string HIDDENSORTEXPRESSIONID = "hidSortExpression";
   /// <summary>
   /// Defines The Hidden Control Name For DataSetXmlSchema
   /// </summary>
   private const string HIDDENSCHEMA = "hidDataSourceSchema";
   /// <summary>
   /// Defines The Hidden Control Name For DataColumnsExtendedProperties
   /// </summary>
   private const string HIDDENDATACOLUMNEXTENDEDPROPERTYSCHEMA = "hidDataColumnExtendedPropertySchema";
   /// <summary>
   /// Defines The Int Zero
   /// </summary>
   private const int INT_ZERO = 0;
   /// <summary>
   /// Defines The Int One
   /// </summary>
   private const int INT_ONE  = 1;
   /// <summary>
   /// Defines The Two
   /// </summary>
   private const int INT_TWO  = 2;
   /// <summary>
   /// Defines The Int Negative One
   /// </summary>
   private const int INT_NEGATIVE_ONE = -1;
   /// <summary>
   /// Defines The String Colan
   /// </summary>
   private const string COLON = ":";
   /// <summary>
   /// Defines The String Underscore
   /// </summary>
   private const string UNDERSCORE = "_";

   /// <summary>
   /// Defines The String Message For EventNull
   /// </summary>
   private const string EVENTNULL = " Event Is Null";
   /// <summary>
   /// Defines The Hidden Control Name For DataMember
   /// </summary>
   private const string HIDDENDATAMEMBERNAME = "hidDataMember";
   /// <summary>
   /// Defines The Hidden Control Name For CurrentRowNumber
   /// </summary>
   private const string HIDDENROWNUMBER = "hidCurrentRowNumber";
   /// <summary>
   /// Defines The Hidden Control Name For EditEvent
   /// </summary>
   private const string HIDDENEDITEVENT = "hidEditEvent";
   /// <summary>
   /// Defines The Hidden Control Name For CheckBoxStateData
   /// </summary>
   private const string HIDDENCHECKBOXSTATEDATA = "hidCheckBoxStateData";
   /// <summary>
   /// Defines The Hidden Control Name For DeleteEvent
   /// </summary>
   private const string HIDDENDELETEEVENT = "hidDeleteEvent";
   /// <summary>
   /// Defines The ClinentSide Function DeleteMe
   /// </summary>
   private const string DELETEMEFUNCTIONNAME = "DeleteMe()";
   /// <summary>
   /// Defines The ClientSide Function EditMe();
   /// </summary>
   private const string EDITMEFUNCTIONNAME = "EditMe()";
   /// <summary>
   /// Defines The Hidden Control Name For OldStyleSheet
   /// </summary>
   private const string HIDDENOLDSTYLECONTROL = "hidoldStyleControl";
   /// <summary>
   /// Defines The Client Side Function For SelectedRowNo
   /// </summary>
   private const string SELECTEDROWNOFUNCTIONNAME = "SelectedRowNo()";
   /// <summary>
   /// Defines The Client Side Function For SelectedRowId
   /// </summary>
   private const string SELECTEDROWIDFUNCTIONNAME = "SelectedRowId()";
   /// <summary>
   /// Defines The CheckboxState Client Side Function Paramater Name.
   /// </summary>
   private const string CHECKBOXSTATEROWTYPE = "rowtype"; 
   /// <summary>
   /// Defines The CheckboxState Client Side Function Paramater Name.
   /// </summary>
   private const string CHECKBOXSTATETABLENAME = "tablename";   
   /// <summary>
   /// Defines The CheckboxState Client Side Function Paramater Name.
   /// </summary>
   private const string CHECKBOXSTATEROW = "row";
   /// <summary>
   /// Defines The CheckboxState Client Side Function Paramater Name.
   /// </summary>
   private const string CHECKBOXSTATECELL = "cell";
   /// <summary>
   /// Defines The Client Side Function For CheckBoxState;
   /// </summary>
   private const string CHECKBOXSTATEFUNCTIONNAME = "CheckBoxState("+ CHECKBOXSTATEROWTYPE +","+ CHECKBOXSTATETABLENAME +","+ CHECKBOXSTATEROW +","+ CHECKBOXSTATECELL +")";
   /// <summary>
   /// Defines The Delete Message Used By ClientSide Confirm
   /// </summary>
   private const string DELETECONFIRMATIONMESSAGE = "Proceed With Deletetion Process";
   /// <summary>
   /// Defines The Cancel Message Used By ClientSide Confirm
   /// </summary>
   private const string CANCELCONFIRMATIONMESSAGE = "Proceed With Cancelation Process";
   /// <summary>
   /// Defines The Text For Edit Link
   /// </summary>
   private const string EDIT   = "Edit";
   /// <summary>
   /// Defines The text For Apply Link
   /// </summary>
   private const string APPLY  = "Apply";
   /// <summary>
   /// Defines The Text For Cancel Link
   /// </summary>
   private const string CANCEL = "Cancel";
   /// <summary>
   /// Defines The Text For Delete Link
   /// </summary>
   private const string DELETE = "Delete";
   /// <summary>
   /// Defines The Text For SelectOnSingle Click String Builder
   /// </summary>
   private const string SELECTONSINGLECLICKSTRINBUILDER = "sbSelectOnSingleClick";
   /// <summary>
   /// Defines The ClientSideFunction Name For SelectOnSingleClick;
   /// </summary>
   private const string SELECTONSINGLECLICK = "SelectOnSingleClick";
   /// <summary>
   /// Defines The ClientSide Function Name & Signature.
   /// </summary>
   private const string SELECTONSINGLECLICKFUNCTIONNAME = SELECTONSINGLECLICK + "(row, baseclassname, selectedclassname, tablename, type, hidcontrol, hidstylecontrol)";
   /// <summary>
   /// Defines The Text For Delete Click String Builder
   /// </summary>
   private const string DELETEEVENT = "sbDeleteEventClick";
   /// <summary>
   /// Defines The Text For Edit Click String Builder
   /// </summary>
   private const string EDITEVENT = "sbEditEventClick";
   /// <summary>
   /// Defines The Text For Slected String Builder
   /// </summary>
   private const string STRINGBUILDERSELECTEDROWNO = "sbSelectedRowNo";
   /// <summary>
   /// Defines The Text For Slected String Builder
   /// </summary>
   private const string STRINGBUILDERSELECTEDROWID = "sbSelectedRowId";
   /// <summary>
   /// Defines The Text For OnClick
   /// </summary>
   private const string ONCLICK = "onclick";
   /// <summary>
   /// Defines The Text For OnDblClick
   /// </summary>
   private const string ONDBLCLICK = "ondblClick";
   /// <summary>
   /// Defines The Text For CssClass
   /// </summary>
   private const string CSSCLASS = "alladindatagridcssclass";
   /// <summary>
   /// Defines The Text For Header Cssclass
   /// </summary>
   private const string HEADERCSSCLASS = "alladindatagridheadercssclass";
   /// <summary>
   /// Defines The Text For Item CssClass
   /// </summary>
   private const string ITEMCSSCLASS = "alladindatagriditemcssclass";
   /// <summary>
   /// Defines The Text For Alternating CssClass
   /// </summary>
   private const string ALTERNATINGITEMCSSCLASS = "alladindatagridalternatingitemcssclass";
   /// <summary>
   /// Defines The Text For SelectedItem Css Class
   /// </summary>
   private const string SELECTEDITEMCSSCLASS = "alladindatagridselecteditemcssclass";
   /// <summary>
   /// Defines The Text For Footer CssClass
   /// </summary>
   private const string FOOTERCSSCLASS = "alladindatagridfootercssclass";
   /// <summary>
   /// Defines The Text For Pager CssClass
   /// </summary>
   private const string PAGERCSSCLASS = "alladindatagridpagercssclass";
   /// <summary>
   /// Defines The Text For PageSize
   /// </summary>
   private const string PAGESIZE = "alladindatagridpagesize";
   /// <summary>
   /// Defines The Text For Boolean Type
   /// </summary>
   private const string SYSTEMBOOLEAN  = "System.Boolean";
   /// <summary>
   /// Defines The Text For Decimal Type
   /// </summary>
   private const string SYSTEMDECIMAL  = "System.Decimal";
   /// <summary>
   /// Defines the Text For Int16 Type
   /// </summary>
   private const string SYSTEMINT16    = "System.Int16";
   /// <summary>
   /// Defines the Text For Int32 Type
   /// </summary>
   private const string SYSTEMINT32    = "System.Int32";
   /// <summary>
   /// Defines the Text For Int64 Type
   /// </summary>
   private const string SYSTEMINT64    = "System.Int64";
   /// <summary>
   /// Defines the Text For DateTime Type
   /// </summary>
   private const string SYSTEMDATETIME = "System.DateTime";
   /// <summary>
   /// Defines the Text For String Type
   /// </summary>
   private const string SYSTEMSTRING = "System.String";
   /// <summary>
   /// Defines the Text For Numeric Format Type
   /// </summary>
   private const string NUMERICFORMAT = "NumericFormat";
   /// <summary>
   /// Defines The Text For horizontalalignbool
   /// </summary>
   private const string HORIZONTALALIGNBOOL     = "alladindatagridhorizontalalignbool";
   /// <summary>
   /// Defines The Text For horizontalaligndatatime
   /// </summary>
   private const string HORIZONTALALIGNDATATIME = "alladindatagridhorizontalaligndatatime";
   /// <summary>
   /// Defines The Text For horizontalalignstring
   /// </summary>
   private const string HORIZONTALALIGNSTRING   = "alladindatagridhorizontalalignstring";
   /// <summary>
   /// Defines The Text For horizontalalignnumeric
   /// </summary>
   private const string HORIZONTALALIGNNUMERIC  = "alladindatagridhorizontalalignnumeric";
   /// <summary>
   /// Defines The Text For verticalalignbool
   /// </summary>
   private const string VERTICALALIGNBOOL     = "alladindatagridverticalalignbool";
   /// <summary>
   /// Defines The Text For verticalaligndatetime
   /// </summary>
   private const string VERTICALALIGNDATATIME = "alladindatagridverticalaligndatatime";
   /// <summary>
   /// Defines The Text For verticalalignstring
   /// </summary>
   private const string VERTICALALIGNSTRING   = "alladindatagridverticalalignstring";
   /// <summary>
   /// Defines The Text For verticalalignnumeric
   /// </summary>
   private const string VERTICALALIGNNUMERIC  = "alladindatagridverticalalignnumeric";
   /// <summary>
   /// Defines The Text For datetimeformat
   /// </summary>
   private const string DATETIMEFORMAT = "alladindatagriddatetimeformat";
   /// <summary>
   /// Defines The Text For Date Picker Client Function Message
   /// </summary>
   private const string DATEPICKERCLIENTFUNCTIONEXCEPTIONMESSAGE = "DatePickerClientSideFunction Property Must Be A Valid Javascript Function Call With i.e. functionname()";
   /// <summary>
   /// Defines The Text For ExtendedProperties DataSetName
   /// </summary>
   private const string EXTENDEDPROPERTYDATASETNAME   = "AlladinExtendedPropertyDataSet";
   /// <summary>
   /// Defines The Text For ExtendedProperties DataTable
   /// </summary>
   private const string EXTENDEDPROPERTYDATATABLENAME = "AlladinExtendedPropertyDataTable";   
   /// <summary>
   /// Defines The Text For ExtendedProperties ColumnName
   /// </summary>
   private const string EXTENDEDPROPERTYCOLUMNNAME    = "AlladinExtendedPropertyColumnName";
   /// <summary>
   /// Defines The Text For ExtendedProperties Key
   /// </summary>
   private const string EXTENDEDPROPERTYKEY           = "AlladinExtendedPropertyKey";  
   /// <summary>
   /// Defines The Text For ExtendedProperties Value
   /// </summary>
   private const string EXTENDEDPROPERTYVALUE         = "AlladinExtendedPropertyValue";
   /// <summary>
   /// Defines The Text For DropDownList DefaultText
   /// </summary>
   private const string DROPDOWNLISTDEFAULTTEXTFIELD = "SELECT";
   /// <summary>
   /// Defines The Text For DropDownList TextString
   /// </summary>
   private const string DROPDOWNLISTDEFAULTTEXTSTRING = "alladindatagriddropdownlistdefaulttextstring";
   /// <summary>
   /// Defines The String For Required Field Validator Default Message Key Used In The Web.Config File.
   /// </summary>
   private const string REQUIREDFIELDVALIDATORDEFAULTMESSAGEKEY = "alladindatagridrequiredfieldvalidatordefaultmessage";
   /// <summary>
   /// Defines The String For Required Field Validator Default Message.
   /// </summary>
   private const string REQUIREDFIELDVALIDATORDEFAULTMESSAGE = "Required";
   /// <summary>
   /// Defines The String For Range Field Validator Default Message Key Used In The Web.Config File.
   /// </summary>
   private const string RANGEVALIDATORDEFAULTMESSAGEKEY = "alladindatagridrangevalidatordefaultmessage";
   /// <summary>
   /// Defines The String For Range Field Validator Default Message.
   /// </summary>
   private const string RANGEVALIDATORDEFAULTMESSAGE = "Invalid Data";
   /// <summary>
   /// Defines The String For Range Field Validator Default Decimal Min Value Key Used In The Web.Config File.
   /// </summary>
   private const string RANGEVALIDATORDEFAULTDECIMALMINVALUEKEY = "alladindatagridrangevalidatordefaultdecimalminvalue";
   /// <summary>
   /// Defines The String For Range Field Validator Default Decimal Min Value
   /// </summary>
   private const string RANGEVALIDATORDEFAULTDECIMALMINVALUE = "0";
   /// <summary>
   /// Defines The String For Range Field Validator Default Decimal Max Value Key Used In The Web.Config File.
   /// </summary>
   private const string RANGEVALIDATORDEFAULTDECIMALMAXVALUEKEY = "alladindatagridrangevalidatordefaultdecimalmaxvalue";
   /// <summary>
   /// Defines The String For Range Field Validator Default Decimal Max Value
   /// </summary>
   private const string RANGEVALIDATORDEFAULTDECIMALMAXVALUE = "99999999.99";
   /// <summary>
   /// Defines The String For Range Field Validator Default Integer Min Value Key Used In The Web.Config File.
   /// </summary>
   private const string RANGEVALIDATORDEFAULTINTEGERMINVALUEKEY = "alladindatagridrangevalidatordefaultintegerminvalue";
   /// <summary>
   /// Defines The String For Range Field Validator Default Integer Min Value
   /// </summary>
   private const string RANGEVALIDATORDEFAULTINTEGERMINVALUE = "0";
   /// <summary>
   /// Defines The String For Range Field Validator Default Integer Max Value Key Used In The Web.Config File.
   /// </summary>
   private const string RANGEVALIDATORDEFAULTINTEGERMAXVALUEKEY = "alladindatagridrangevalidatordefaultintegermaxvalue";
   /// <summary>
   /// Defines The String For Range Field Validator Default Integer Max Value
   /// </summary>
   private const string RANGEVALIDATORDEFAULTINTEGERMAXVALUE = "999999999";
   /// <summary>
   /// Defines The String For An ID of a Row or Item
   /// </summary>
   private const string ITEMID = "ID";
   /// <summary>
   /// Defines The String For Edit Column Edit Text Key Used In The Web.Config File.
   /// </summary>
   private const string EDITCOLUMNEDITTEXTKEY = "alladindatagrideditcolumnedittext";
   /// <summary>
   /// Defines The String For Edit Column Update Text Key Used In The Web.Config File.
   /// </summary>
   private const string EDITCOLUMNUPDATETEXTKEY = "alladindatagrideditcolumnupdatetext";
   /// <summary>
   /// Defines The String For Edit Column Cancel Text Key Used In The Web.Config File.
   /// </summary>
   private const string EDITCOLUMNCANCELTEXTKEY = "alladindatagrideditcolumncanceltext";
   /// <summary>
   /// Defines The String For Edit Column Header Text Key Used In The Web.Config File.
   /// </summary>
   private const string EDITCOLUMNHEADERTEXTKEY = "alladindatagrideditcolumnheadertext";
   /// <summary>
   /// Defines The String For Delete Column Delete Text Key Used In The Web.Config File.
   /// </summary>
   private const string DELETECOLUMNDELETETEXTKEY = "alladindatagriddeletecolumndeletetext";
   /// <summary>
   /// Defines The String For Delete Column Header Text Key Used In The Web.Config File.
   /// </summary>
   private const string DELETECOLUMNHEADERTEXTKEY = "alladindatagriddeletecolumnheadertext";
   /// <summary>
   /// Defines The String For ItemRowReadOnlyCssClass Key Used In The Web.Config File.
   /// </summary>
   private const string ITEMREADONLYCSSCLASSKEY = "alladindatagriditemreadonlycssclass";
   /// <summary>
   /// Defines The String For Item Attribute Of Data Row
   /// </summary>
   private const string DATAROWITEMATTRIBUTE = "datarow";
   /// <summary>
   /// Defines The String For ClientSideFunctionName
   /// </summary>
   private const string DATAROWITEMCLIENTFUNCTION = "DataRow()";
   /// <summary>
   /// Defines The String To Store For Table Attribute
   /// </summary>
   private const string TR = "TR";
   /// <summary>
   /// Defines The String For Default Control Abbriviation
   /// </summary>
   private const string CTL = "ctl";
   /// <summary>
   /// Defines The String To Store The Elipse Button Default Value
   /// </summary>
   private const string ELIPSEBUTTONDEFAULTTEXT = "...";
   /// <summary>
   /// Defines The String For ElipseButtonDefaultText Key Used In The Web.Config File.
   /// </summary>
   private const string ELIPSEBUTTONDEFAULTTEXTKEY = "alladindatagridelipsebuttondefaulttext";
   /// <summary>
   /// Defines The String For TextBoxControl;
   /// </summary>
   private const string TEXTBOXCONTROL = "TextBoxControl";
   /// <summary>
   /// Defines The String for ElipseButtonClientSideFunction
   /// </summary>
   private const string ELIPSEBUTTONCLIENTSIDEFUNCTION = "elipsebuttontextboxcontrol("+ TEXTBOXCONTROL +")";
   /// <summary>
   /// Defines The String For bool Type True
   /// </summary>
   private const string TRUE = "true";
   /// <summary>
   /// Defines The String For bool Type False
   /// </summary>
   private const string FALSE = "false";
   /// <summary>
   /// Defines The string For Hidden Commandsource TextBox
   /// </summary>
   private const string HIDDENCOMMANDNAME = "hidCommandSource";
   /// <summary>
   /// Defines The Default .Net ClientSide Function
   /// </summary>
   private const string DOPOSTBACKCLIENTFUNCTION = "__doPostBack";
   /// <summary>
   /// Defines The Default .Net SpecialCharactor
   /// </summary>
   private const string DOLLAR = "$";
   /// <summary>
   /// Defines The String For ReadOnlyTextBox Key Used In The Web.Config File.
   /// </summary>
   private const string READONLYTEXTBOXKEY = "alladindatagridreadonlytextboxcss";
   /// <summary>
   /// Defines The String For DeleteLinkColumn Key Used In The Web.Config File.
   /// </summary>
   private const string DELETELINKCOLUMNKEY = "alladindatagriddeletelinkcolumn";
   /// <summary>
   /// Defines The String For EditLinkColumn Key Used In The Web.Config File.
   /// </summary>
   private const string EDITLINKCOLUMNKEY = "alladindatagrideditlinkcolumn";
   /// <summary>
   /// Defines The String For DeleteLink Exception Message
   /// </summary>
   private const string DELETELINKEXCEPTIONMESSAGE = "DeleteLink Column Ordinal Must Be Set To SecondColumn";
   /// <summary>
   /// Defines The String For EditLink Exception Message.
   /// </summary>
   private const string EDITLINKEXCEPTIONMESSAGE = "EditLink Column Ordinal Must Be Set To SecondColumn";
   /// <summary>
   /// Defines The String For EditLink & DeleteLink Exception Message.
   /// </summary>
   private const string EDITDELETELINKEXCEPTIONMESSAGE = "EditLinkColumnOrdinal & DeleteLinkColumnOrdinal Cannot Be The Same";
   /// <summary>
   /// Defines The String For Style Attribute
   /// </summary>
   private const string STYLE = "style";
   /// <summary>
   /// Defines The String For text align in CSS Style
   /// </summary>
   private const string TEXTALIGN = "text-align:";
   /// <summary>
   /// Defines The String For Item CellWrap Key Used In The Web.Config File.
   /// </summary>
   private const string ITEMCELLWRAPKEY = "alladindatagriditemcellwrapkey";
   /// <summary>
   /// Defines The String For DateControlTextBoxType Key Used In The Web.Config File.
   /// </summary>
   private const string DATECONTROLTEXTBOXTYPEKEY = "alladindatagriddatecontroltextboxtype";
   /// <summary>
   /// Defines The String For ElipseButtonTextBoxType Key Used In The Web.Config File.
   /// </summary>
   private const string ELIPSEBUTTONTEXTBOXTYPEKEY = "alladindatagridelipsebuttontextboxtype";
   /// <summary>
   /// Defines The String For TotalNumberPages Hidden Control Name
   /// </summary>
   private const string HIDDENTOTALNUMBERPAGES = "hidTotalNumberOfPages";
   /// <summary>
   /// Defines The string Of NoRecords Message
   /// </summary>
   private const string NORECORDMESSAGE = "No Records Exists In The System";
   /// <summary>
   /// Defines The String For noRecordMessage Key Used In The Web.Config File.
   /// </summary>
   private const string NORECORDMESSAGEKEY = "alladindatagridnorecordmessage";
   /// <summary>
   /// Defines The String For PageNumber DataColumn Name.
   /// </summary>
   private const string PAGENUMBERDATACOLUMN = "PageNumber";
   /// <summary>
   /// Defines The String For ClientSide Function CheckBoxStateRecordCount.
   /// </summary>
   private const string CHECKBOXSTATERECORDCOUNTFUNCTIONNAME = "CheckBoxStateRecordCount()";
   /// <summary>
   /// Defines The String For ClientSide Function CheckBoxStateHeaderCheck.
   /// </summary>
   private const string CHECKBOXSTATEHEADERCHECKFUNCTIONNAME = "CheckBoxStateHeaderCheck()";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string DELETETYPEWEBCONFIGKEY = "alladindatagriddeletetype";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string DELETECONFIRMATIONMESSAGEWEBCONFIGKEY = "alladindatagriddeleteconfirmationmessage";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string CANCELTYPEWEBCONFIGKEY = "alladindatagridcanceltype";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string CANCELCONFIRMATIONMESSAGEWEBCONFIGKEY = "alladindatagridcancelconfirmationmessage";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string DATEPICKERIMAGELOCATIONWEBCONFIGKEY = "alladindatagriddatepickerimagelocation";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string CAPTIONCONTROLEDITDELETELINKWEBCONFIGKEY = "alladindatagridcaptioncontroleditdeletelink";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string EDITLINKIMAGELOCATIONWEBCONFIGKEY = "alladindatagrideditlinkimagelocation";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string DELETELINKIMAGELOCATIONWEBCONFIGKEY = "alladindatagriddeletelinkimagelocation";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string APPLYLINKIMAGELOCATIONWEBCONFIGKEY = "alladindatagridapplylinkimagelocation";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string CANCELLINKIMAGELOCATIONWEBCONFIGKEY = "alladindatagridcancellinkimagelocation";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string PAGEMODEWEBCONFIGKEY = "alladindatagridpagemode";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string PAGEPOSITIONWEBCONFIGKEY = "alladindatagridpageposition";
   /// <summary>
   /// Defines The String That Matches With The key In The Web.config File.
   /// </summary>
   private const string BORDERCOLORWEBCONFIGKEY = "alladindatagridbordercolor";
            /// <summary>
            /// ASP.Net 2.0 Formatting For The Grid
            /// </summary>
            //private const string ASPNETTWOFORMAT = "__Page_";
  #endregion
  #region Custom Events
   /// <summary>
   /// Fires For Rebinding The Grid.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Fires For Rebinding The Grid.")]
   public event DataGridDataBinding AlladinsDataBinding;
   /// <summary>
   /// Fires When An Exception Is Raised Within The Grid.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Fires When An Exception Is Raised Within The Grid.")]
   public event DataGridException AlladinDataGridException;
   /// <summary>
   /// Fires When An Items Update Event Is Fired Within The Grid.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Fires When An Items Update Event Is Fired Within The Grid.")]
   public event DataGridRow AlladinDataGridUpdateRow;
   /// <summary>
   /// Fires When An Items Delete Event Is Fired Within The Grid.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Fires When An Items Delete Event Is Fired Within The Grid.")]
   public event DataGridRow AlladinDataGridDeleteRow;
   /// <summary>
   /// Fires When An Items Edit or ItemCommand Event Is Fired And The EditType Is PageRedirect Within The Grid.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Fires When An Items Edit or ItemCommand Event Is Fired And The EditType Is PageRedirect Within The Grid.")]
   public event DataGridPageRedirect AlladinDataGridPageRedirectRow;
  #endregion
  #region Member Variable Declaration Region
   /// <summary>
   /// Stores The Data Of Sort Direction
   /// </summary>
   private string strSortDirection = SORTDESC;
   /// <summary>
   /// Stores The Data Of Sort Expression
   /// </summary>
   private string strSortExpression = string.Empty;
   /// <summary>
   /// Stores The Data Of Bounded Data Sources Schema i.e. Dataset Schema
   /// </summary>
   private string strSchemaXML;
   /// <summary>
   /// Stores The Data of DataSource i.e. Bounded Dataset
   /// </summary>
   private DataSet dsGridData = new DataSet();
   /// <summary>
   /// Stores The Data Of The Grids ClientId
   /// </summary>
   private string strDataGridClientId;

   /// <summary>
   /// Stores The Data Of The DataMember i.e. Bounded Datasets DataTable
   /// </summary>
   private string strDataMemberName;
   /// <summary>
   /// Stores The Data Of FullyEditable DataGrid
   /// </summary>
   private bool blnFullyEditable = false;
   /// <summary>
   /// Stores The Data Of DeleteColumnVisibility i.e. To Render The Delete Link On Client Side
   /// </summary>
   private bool blnDeleteColumnVisibility = false;
   /// <summary>
   /// Stores The Data Of EditColumnVisibility i.e. To Render The Edit Link On Client Side
   /// </summary>
   private bool blnEditColumnVisibility = false;
   /// <summary>
   /// Stores The Data Of SelectOnSingleClick i.e. To Change the Color OnClicking The Grid Item or Row
   /// </summary>
   private bool blnSelectOnSingleClick = true;
   /// <summary>
   /// Stores The Data Of RowNumber i.e. The SelectedRow Row Number
   /// </summary>
   private int intHiddenSelectedRowNumber = INT_NEGATIVE_ONE;
   /// <summary>
   /// Stores The Data Of RowNumber's Client Side Hidden Control
   /// </summary>
   private string strHiddenSelectedRowNumber;
   /// <summary>
   /// Stores The Data DataGridClientId
   /// </summary>
   private string strDataGridClientIdForJavaScript;
   /// <summary>
   /// Stores The Data Of EditOnDoubleClick i.e. To Add ClientSide DoubleClick Event
   /// </summary>
   private bool blnEditOnDoubleClick = true;
   /// <summary>
   /// Stores The Data Of EditEvent i.e. ClientSide EditEvent Function
   /// </summary>
   private string strHiddenEditEvent;
   /// <summary>
   /// Stores The Data Of DeleteEvent i.e. ClientSide DeleteEvent Function
   /// </summary>
   private string strHiddenDeleteEvent;
   /// <summary>
   /// Stores The Data Of DeleteClientButton Client Id
   /// </summary>
   private string strDeleteClientButton;
   /// <summary>
   /// Stores The Data Of EditClientButton Client Id
   /// </summary>
   private string strEditClientButton;
   /// <summary>
   /// Stores The Data Of Edit Client Function Name
   /// </summary>
   private string strEditClientFunctionName;
   /// <summary>
   /// Stores The Data Of Delete Client Function Name
   /// </summary>
   private string strDeleteClientFunctionName;
   /// <summary>
   /// Stores The Data Of OldStyleControl Client Id
   /// </summary>
   private string strHiddenOldStyleControl;
   /// <summary>
   /// Stores The Data Of Selected Row No Client Function Name
   /// </summary>
   private string strSelectedRowNoClientFunctionName;
   /// <summary>
   /// Stores The Data Of Selected Row ID Client Function Name
   /// </summary>
   private string strSelectedRowIdClientFunctionName;
   /// <summary>
   /// Stores The Data Of Delete Type
   /// </summary>
   private deletetype deletetypeDeleteType;
   /// <summary>
   /// Stores The Data Of Edit Type
   /// </summary>
   private edittype edittypeEditType;
   /// <summary>
   /// Stores The Data Of Delete Confirmation Message
   /// </summary>
   private string strDeleteConfirmationMessage = DELETECONFIRMATIONMESSAGE;
   /// <summary>
   /// Stores The Data Of Cancel Type
   /// </summary>
   private canceltype canceltypeCancelType;
   /// <summary>
   /// Stores The Data Of Cancel Confirmation Message
   /// </summary>
   private string strCancelConfirmationMessage = CANCELCONFIRMATIONMESSAGE;
   /// <summary>
   /// Stores The Data Of Item Cell Start Counter For Mapping With DataColumns or DataRows;
   /// </summary>
   private int intStartCellFrom = INT_TWO;
   /// <summary>
   /// Stores The Data Of DataColumn counter variable
   /// </summary>
   private int intDataColumnCounter = INT_ZERO;
   /// <summary>
   /// Stores The Data Of Horizontal Align Boolean DataType
   /// </summary>
   private HorizontalAlign horizontalalignBoolean = HorizontalAlign.Center;
   /// <summary>
   /// Stores The Data Of Horizontal Align DateTime DataType
   /// </summary>
   private HorizontalAlign horizontalalignDateTime = HorizontalAlign.Left;
   /// <summary>
   /// Stores The Data Of Horizontal Align String DataType
   /// </summary>
   private HorizontalAlign horizontalalignString = HorizontalAlign.Left;
   /// <summary>
   /// Stores The Data Of Horizontal Align Numeric DataType
   /// </summary>
   private HorizontalAlign horizontalalignNumeric = HorizontalAlign.Right;
   /// <summary>
   /// Stores The Data Of Vertical Align Boolean DataType
   /// </summary>
   private VerticalAlign verticalalignBoolean = VerticalAlign.Top;
   /// <summary>
   /// Stores The Data Of Vertical Align Boolean DataType
   /// </summary>
   private VerticalAlign verticalalignDateTime = VerticalAlign.Top;
   /// <summary>
   /// Stores The Data Of Vertical Align String DataType
   /// </summary>
   private VerticalAlign verticalalignString = VerticalAlign.Top;
   /// <summary>
   /// Stores The Data Of Item Cells Vertical Alignment Of Numeric Datatype
   /// </summary>
   private VerticalAlign verticalalignNumeric = VerticalAlign.Top;
   /// <summary>
   /// Stores The Data Of Item Cells Datetime DataType Date Format
   /// </summary>
   private string strDateFormat;
   /// <summary>
   /// Stores The Data For Date Pickers Image Location
   /// </summary>
   private string strDatePickerImageLocation;
   /// <summary>
   /// Stores The Data For Date Pickers Client Side Function
   /// </summary>
   private string strDatePickerClientSideFunction;
   /// <summary>
   /// Stores The Data For DataColumns ExtendedProperties Xml Schema.
   /// </summary>
   private string strDataColumnExtendedPropertySchema;
   /// <summary>
   /// Stores The Data for DropDownList Dafult Text.
   /// </summary>
   private string strDropDownListDefaultTextField = DROPDOWNLISTDEFAULTTEXTFIELD;
   /// <summary>
   /// Stores The Data of Required Field Validator Default Message
   /// </summary>
   private string strRequiredFieldValidatorDefaultMessage = REQUIREDFIELDVALIDATORDEFAULTMESSAGE;
   /// <summary>
   /// Stores The Data of Range Field Validator Default Message
   /// </summary>
   private string strRangeValidatorDefaultMessage = RANGEVALIDATORDEFAULTMESSAGE;
   /// <summary>
   /// Stores The Data of Range Field Validator Default Decimal Min Value
   /// </summary>
   private string strRangeValidatorDefaultDecimalMinValue = RANGEVALIDATORDEFAULTDECIMALMINVALUE;
   /// <summary>
   /// Stores The Data of Range Field Validator Default Decimal Max Value
   /// </summary>
   private string strRangeValidatorDefaultDecimalMaxValue = RANGEVALIDATORDEFAULTDECIMALMAXVALUE;
   /// <summary>
   /// Stores The Data of Range Field Validator Default Integer Min Value
   /// </summary>
   private string strRangeValidatorDefaultIntegerMinValue = RANGEVALIDATORDEFAULTINTEGERMINVALUE;
   /// <summary>
   /// Stores The Data of Range Field Validator Default Integer Max Value
   /// </summary>
   private string strRangeValidatorDefaultIntegerMaxValue = RANGEVALIDATORDEFAULTINTEGERMAXVALUE;
   /// <summary>
   /// Stores Data Of The DataColumn Name Based On Which To Make An Item or Row ReadOnly Conditional.
   /// </summary>
   private string strItemReadOnlyColumnName = string.Empty;
   /// <summary>
   /// Stores Data Of The Css Class Name Based On Which To Change the Back Color of Item or Row Conditionally.
   /// </summary>
   private string strItemReadOnlyCssClass;
   /// <summary>
   /// Stores The Data Of EditColumn Edit Text
   /// </summary>
   private string strEditColumnEditText = EDIT;
   /// <summary>
   /// Stores The Data Of EditColumn Header Text
   /// </summary>
   private string strEditColumnHeaderText = EDIT;
   /// <summary>
   /// Stores The Data Of EditColumn Update Text
   /// </summary>
   private string strEditColumnUpdateText = APPLY;
   /// <summary>
   /// Stores The Data Of EditColumn Cancel Text
   /// </summary>
   private string strEditColumnCancelText = CANCEL;   
   /// <summary>
   /// Stores The Data Of DeleteColumn Delete Text
   /// </summary>
   private string strDeleteColumnDeleteText = DELETE;
   /// <summary>
   /// Stores The Data Of DeleteColumn Header Text
   /// </summary>
   private string strDeleteColumnHeaderText = DELETE;
   /// <summary>
   /// Stores The Data Of DataRow In Grid Item
   /// </summary>
   private bool blnPersistDataRowInGridItem;
   /// <summary>
   /// Stores The Data Of The Client Side Function Name For DataRow;
   /// </summary>
   private string strClientSideFunctionForDataRow = DATAROWITEMCLIENTFUNCTION;
   /// <summary>
   /// Stores The Data Of ElipseButton Default Text
   /// </summary>
   private string strElipseButtonDefaultText = ELIPSEBUTTONDEFAULTTEXT;
   /// <summary>
   /// Stores The Data of ElipseButton ClientSide Function
   /// </summary>
   private string strElipseButtonClientSideFunction = ELIPSEBUTTONCLIENTSIDEFUNCTION;
   /// <summary>
   /// Stores The Data of CommandSource Texbox Control Name
   /// </summary>
   private string strHiddenCommandName;
   /// <summary>
   /// Stores The Data Of CommandSource Which Triggered The Edit Command Event.
   /// </summary>
   private string strCommandName;
   /// <summary>
   /// Stores The Data Of ReadOnlyTextBoxCss i.e. StyleSheet Name.
   /// </summary>
   private string strReadOnlyTextBoxCss = string.Empty;
   /// <summary>
   /// Stores Data For EditLink Column Ordinal
   /// </summary>
   private Int16 intEditLinkColumnOrdinal = INT_ZERO;
   /// <summary>
   /// Stores Data For EditLink Column Ordinal
   /// </summary>
   private Int16 intDeleteLinkColumnOrdinal = INT_ONE;
   /// <summary>
   /// Stores Data For CaptionType
   /// </summary>
   private captiontype captiontypeCaptionControlEditDeleteLink = captiontype.Text;
    /// <summary>
   /// Stores The Data For Edit Link Image Location
   /// </summary>
   private string strEditLinkImageLocation = string.Empty;
   /// <summary>
   /// Stores The Data For Delete Link Image Location
   /// </summary>
   private string strDeleteLinkImageLocation = string.Empty;
   /// <summary>
   /// Stores The Data For Apply Link Image Location
   /// </summary>
   private string strApplyLinkImageLocation = string.Empty;
   /// <summary>
   /// Stores The Data For Cancel Link Image Location
   /// </summary>
   private string strCancelLinkImageLocation = string.Empty;
   /// <summary>
   /// Stores The Data For Item or Row CellWrap
   /// </summary>
   private bool blnItemCellWrap = false;
   /// <summary>
   /// Stores The Data For DateControl TextBox Type
   /// </summary>
   private textboxtype textboxtypeDateControl = textboxtype.ReadOnly;
   /// <summary>
   /// Stores The Data For ElipseButton TextBox Type
   /// </summary>
   private textboxtype textboxtypeElipseButtonControl = textboxtype.ReadOnly;
   /// <summary>
   /// Stores The Data For PagerItem Counter;
   /// </summary>
   private int intPagerCounter = 0;
   /// <summary>
   /// Stores The Data Of Total Number Of Pages.
   /// </summary>
   private Decimal decimalTotalNumberOfPages = 0;
   /// <summary>
   /// Stores the Data Of NoRecords Message.
   /// </summary>
   private string strNoRecordMessage = NORECORDMESSAGE;
   /// <summary>
   /// Stores The Data Of checkboxstate from enum type.
   /// </summary>
   private checkboxstate checkboxstateCheckBoxState = checkboxstate.NoState;
   /// <summary>
   /// Stores The Data Of CheckBoxState DataColumnName
   /// </summary>
   private string strCheckBoxStateColumnName = string.Empty;
   /// <summary>
   /// Stores The Data Of CheckBoxState ClientSide Function.
   /// </summary>
   private string strClientSideFunctionForCheckBoxState;
   /// <summary>
   /// Stores The Data Of CheckBoxState.
   /// </summary>
   private DataSet dsCheckBoxState = new DataSet();
   /// <summary>
   /// Stores The Data of ClientSide Function Name Of CheckBoxStateRecordCount;
   /// </summary>
   private string strClientSideFunctionForCheckBoxStateRecordCount;
   /// <summary>
   /// Stores The Data Of ReadOnly Item Counts Of DataGrid.
   /// </summary>
   private int intReadOnlyItemCount = INT_ZERO;
   /// <summary>
   /// Stores The Data of ClientSide Function Name Of CheckBoxStateHeaderCheckbox;
   /// </summary>
   private string strClientSideFunctionForCheckBoxStateHeaderCheck;
  #endregion
  #region Property Declaration Region
   /// <summary>
   /// Specify if the Grid Will Be Fully Editable.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Specify if the Grid Will Be Fully Editable.")]
   public bool FullEditable
   {
    get
    {
     return this.blnFullyEditable;
    }
    set
    {
     this.blnFullyEditable = value; 
    }
   }
   /// <summary>
   /// Specify if the Grids Delete Column Will Be Visible or No.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Specify if the Grids Delete Column Will Be Visible or No.")]
   public bool DeleteColumnVisibility
   {
    get
    {
     return this.blnDeleteColumnVisibility;
    }
    set
    {
     this.blnDeleteColumnVisibility = value;
    }
   }
   /// <summary>
   /// Specify if the Grids Edit Column Will Be Visible or No.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Specify if the Grids Edit Column Will Be Visible or No.")]
   public bool EditColumnVisibility
   {
    get
    {
     return this.blnEditColumnVisibility;
    }
    set
    {
     this.blnEditColumnVisibility = value;
    }
   }
   /// <summary>
   /// Specify if the Grids Row Gets Selected On Single Click.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Specify if the Grids Row Gets Selected On Single Click.")]
   public bool SelectOnSingleClick
   {
    get
    {
     return this.blnSelectOnSingleClick;
    }
    set
    {
     this.blnSelectOnSingleClick = value;
    }
   }
   /// <summary>
   /// Grids Row Gets Posted Back When Mouse Double Click Event Is Fired On The Client Side And Fires The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Grids Row Gets Posted Back When Mouse Double Click Event Is Fired On The Client Side And Fires The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.")]
   public bool EditOnDoubleClick
   {
    get
    {
     return this.blnEditOnDoubleClick;
    }
    set
    {
     this.blnEditOnDoubleClick = value;
    }
   }
   /// <summary>
   /// Explicit Page Button Control Name For Firing AlladinDataGrid DeleteRow Custom Event.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Explicit Page Button Control Name For Firing AlladinDataGrid DeleteRow Custom Event.")]
   public string DeleteClientButton
   {
    get
    {
     return this.strDeleteClientButton;
    }
    set
    {
     this.strDeleteClientButton = value;
    }
   }
   /// <summary>
   /// Explicit Page Button Control Name For Firing The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Explicit Page Button Control Name For Firing The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.")]
   public string EditClientButton
   {
    get
    {
     return this.strEditClientButton;
    }
    set
    {
     this.strEditClientButton = value;
    }
   }  
   /// <summary>
   /// Client Side Function Name For Firing The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Function Name For Firing The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.")]
   public string EditClientFunctionName
   {
    get
    {
     return this.strEditClientFunctionName;
    }
   }
   /// <summary>
   /// Client Side Function Name To Fire AlladinDataGridDeleteRow Post Back Event.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Function Name To Fire AlladinDataGridDeleteRow Post Back Event.")]
   public string DeleteClientFunctionName
   {
    get
    {
     return this.strDeleteClientFunctionName;
    }
   }
   /// <summary>
   /// Client Side Function Name That Returns The Selected Row Number.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Function Name That Returns The Selected Row Number.")]
   public string SelectedRowNoClientFunctionName
   {
    get
    {
     return this.strSelectedRowNoClientFunctionName;
    }
   }
   /// <summary>
   /// Client Side Function Name That Returns The Selected Row Id Which Is The PrimaryKey Of The Binded Datamember.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Function Name That Returns The Selected Row Id Which Is The PrimaryKey Of The Binded Datamember.")]
   public string SelectedRowIdClientFunctionName
   {
    get
    {
     return this.strSelectedRowIdClientFunctionName;
    }
   }
   /// <summary>
   /// Client Side Alert Confirm Message Before Firing AlladinDataGridDeleteRow Post Back Event.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Alert Confirm Message Before Firing AlladinDataGridDeleteRow Post Back Event.")]
   public deletetype DeleteType
   {
    get
    {
     return this.deletetypeDeleteType;
    }
    set
    {
     this.deletetypeDeleteType = value;
    }
   }
   /// <summary>
   /// Client Side Alert Confirm Message Before Firing The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Alert Confirm Message Before Firing The DataGrid Edit Command Event or AlladinDataGrid PageRedirect Event Based On The EditType Custom Property.")]
   public edittype EditType
   {
    get
    {
     return this.edittypeEditType;
    }
    set
    {
     this.edittypeEditType = value;
    }
   }
   /// <summary>
   /// Client Side Alert Message Description Before Firing AlladinDataGridDeleteRow Post Back Event.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Alert Message Description Before Firing AlladinDataGridDeleteRow Post Back Event.")]
   public string DeleteConfirmationMessage
   {
    get
    {
     return this.strDeleteConfirmationMessage;
    }
    set
    {
     this.strDeleteConfirmationMessage = value;
    }
   }
   /// <summary>
   /// Client Side Alert Confirm Message Before Firing DataGrid Cancel Post Back Event.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Alert Confirm Message Before Firing DataGrid Cancel Post Back Event.")]
   public canceltype CancelType
   {
    get
    {
     return this.canceltypeCancelType;
    }
    set
    {
     this.canceltypeCancelType = value;
    }
   }
   /// <summary>
   /// Client Side Alert Message Description Before Firing Cancel Post Back Event.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Alert Message Description Before Firing Cancel Post Back Event.")]
   public string CancelConfirmationMessage
   {
    get
    {
     return this.strCancelConfirmationMessage;
    }
    set
    {
     this.strCancelConfirmationMessage = value;
    }
   }
   /// <summary>
   /// Horizontal Alignment Of Boolean Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Horizontal Alignment Of Boolean Datatype When Rendered In Item Cell.")]
   public HorizontalAlign BooleanCellHorizontalAlign
   {
    get
    {
     return this.horizontalalignBoolean;
    }
    set
    {
     this.horizontalalignBoolean = value;
    }
   }
   /// <summary>
   /// Horizontal Alignment Of DateTime Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Horizontal Alignment Of DateTime Datatype When Rendered In Item Cell.")]
   public HorizontalAlign DateTimeCellHorizontalAlign
   {
    get
    {
     return this.horizontalalignDateTime;
    }
    set
    {
     this.horizontalalignDateTime = value;
    }
   }  
   /// <summary>
   /// Horizontal Alignment Of String Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Horizontal Alignment Of String Datatype When Rendered In Item Cell.")]
   public HorizontalAlign StringCellHorizontalAlign
   {
    get
    {
     return this.horizontalalignString;
    }
    set
    {
     this.horizontalalignString = value;
    }
   }
   /// <summary>
   /// Horizontal Alignment Of Numeric Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Horizontal Alignment Of Numeric Datatype When Rendered In Item Cell.")]
   public HorizontalAlign NumericCellHorizontalAlign
   {
    get
    {
     return this.horizontalalignNumeric;
    }
    set
    {
     this.horizontalalignNumeric = value;
    }
   }
   /// <summary>
   /// Vertical Alignment Of Boolean Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Vertical Alignment Of Boolean Datatype When Rendered In Item Cell.")]
   public VerticalAlign BooleanCellVerticalAlign
   {
    get
    {
     return this.verticalalignBoolean;
    }
    set
    {
     this.verticalalignBoolean = value;
    }
   }
   /// <summary>
   /// Vertical Alignment Of DateTime Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Vertical Alignment Of DateTime Datatype When Rendered In Item Cell.")]
   public VerticalAlign DateTimeCellVerticalAlign
   {
    get
    {
     return this.verticalalignDateTime;
    }
    set
    {
     this.verticalalignDateTime = value;
    }
   }  
   /// <summary>
   /// Vertical Alignment Of String Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Vertical Alignment Of String Datatype When Rendered In Item Cell.")]
   public VerticalAlign StringCellVerticalAlign
   {
    get
    {
     return this.verticalalignString;
    }
    set
    {
     this.verticalalignString = value;
    }
   }
   /// <summary>
   /// Vertical Alignment Of Numeric Datatype When Rendered In Item Cell.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Vertical Alignment Of Numeric Datatype When Rendered In Item Cell.")]
   public VerticalAlign NumericCellVerticalAlign
   {
    get
    {
     return this.verticalalignNumeric;
    }
    set
    {
     this.verticalalignNumeric = value;
    }
   }  
   /// <summary>
   /// Date Format To Be Used By The Item Cell When Rendered. It Must Be A Valid ms:format-date & ms:format-time, YOU CAN GET INFORMATION ABOUT ms:format-date FROM MSDN OR http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/msformatdatefunction.asp.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Date Format To Be Used By The Item Cell When Rendered. It Must Be A Valid ms:format-date & ms:format-time, YOU CAN GET INFORMATION ABOUT ms:format-date FROM MSDN OR http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/msformatdatefunction.asp")]
   public string DateFormat
   {
    get
    {
     return this.strDateFormat;
    }
    set
    {
     this.strDateFormat = value;
    }
   }  
   /// <summary>
   /// Date Picker Image Location i.e. URL.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Date Picker Image Location i.e. URL.")]
   public string DatePickerImageLocation
   {
    get
    {
     return this.strDatePickerImageLocation;
    }
    set
    {
    this.strDatePickerImageLocation = value;
    }
   }
   /// <summary>
   /// Date Picker ClientSide Function. Control will add one parameter which will be the first parameter i.e. the textbox name to save the picked date.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Date Picker ClientSide Function. Control will add one parameter which will be the first parameter i.e. the textbox name to save the picked date.")]
   public string DatePickerClientSideFunction
   {
    get
    {
     return this.strDatePickerClientSideFunction;
    }
    set
    {
     this.strDatePickerClientSideFunction = value;
    }
   }   
   /// <summary>
   /// Default Text Of The First Item In The List Which AlladinDataGrid Adds Internally.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Default Text Of The First Item In The List Which AlladinDataGrid Adds Internally.")]
   public string DropDownListDefaultTextFieldString
   {
    get
    {
     return this.strDropDownListDefaultTextField;
    }
    set
    {
     this.strDropDownListDefaultTextField = value;
    }
   }
   /// <summary>
   /// Required Field Validator Default Text Message To Be Displayed On The Client Side When The Validator Fires.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Required Field Validator Default Text Message To Be Displayed On The Client Side When The Validator Fires.")]
   public string RequiredFieldValidatorDefaultMessage
   {
    get
    {
     return this.strRequiredFieldValidatorDefaultMessage;
    }
    set
    {
     this.strRequiredFieldValidatorDefaultMessage = value;
    }
   }
   /// <summary>
   /// Range Field Validator Default Text Message To Be Displayed On The Client Side When The Validator Fires.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Range Field Validator Default Text Message To Be Displayed On The Client Side When The Validator Fires.")]
   public string RangeValidatorDefaultMessage
   {
    get
    {
     return this.strRangeValidatorDefaultMessage;
    }
    set
    {
     this.strRangeValidatorDefaultMessage = value;
    }
   }
   /// <summary>
   /// Range Field Validator Default Decimal Min Value To Be Used When The Validator Fires.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Range Field Validator Default Decimal Min Value To Be Used When The Validator Fires.")]
   public string RangeValidatorDefaultDecimalMinValue
   {
    get
    {
     return this.strRangeValidatorDefaultDecimalMinValue;
    }
    set
    {
     this.strRangeValidatorDefaultDecimalMinValue = value;
    }
   }
   /// <summary>
   /// Range Field Validator Default Decimal Max Value To Be Used When The Validator Fires.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Range Field Validator Default Decimal Max Value To Be Used When The Validator Fires.")]
   public string RangeValidatorDefaultDecimalMaxValue
   {
    get
    {
     return this.strRangeValidatorDefaultDecimalMaxValue;
    }
    set
    {
     this.strRangeValidatorDefaultDecimalMaxValue = value;
    }
   }
   /// <summary>
   /// Range Field Validator Default Integer Min Value To Be Used When The Validator Fires.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Range Field Validator Default Integer Min Value To Be Used When The Validator Fires.")]
   public string RangeValidatorDefaultIntegerMinValue
   {
    get
    {
     return this.strRangeValidatorDefaultIntegerMinValue;
    }
    set
    {
     this.strRangeValidatorDefaultIntegerMinValue = value;
    }
   }
   /// <summary>
   /// Range Field Validator Default Integer Max Value To Be Used When The Validator Fires.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Range Field Validator Default Integer Max Value To Be Used When The Validator Fires.")]
   public string RangeValidatorDefaultIntegerMaxValue
   {
    get
    {
     return this.strRangeValidatorDefaultIntegerMaxValue;
    }
    set
    {
     this.strRangeValidatorDefaultIntegerMaxValue = value;
    }
   }  
   /// <summary>
   /// DataColumn Name Based On Which To Make An Item or Row ReadOnly Conditional.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("DataColumn Name Based On Which To Make An Item or Row ReadOnly Conditional.")]
   public string ItemReadOnlyColumnName
   {
    get
    {
     return this.strItemReadOnlyColumnName;
    }
    set
    {
     this.strItemReadOnlyColumnName = value;
    }
   }  
   /// <summary>
   /// Css Class Name Based On Which To Change the Back Color etc.. Of Item Or Row Conditionally.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Css Class Name Based On Which To Change the Back Color etc.. Of Item Or Row Conditionally.")]
   public string ItemReadOnlyCssClass
   {
    get
    {
     return this.strItemReadOnlyCssClass;
    }
    set
    {
     this.strItemReadOnlyCssClass = value;
    }
   }
   /// <summary>
   /// Edit Column Edit Text That Displays On The Edit Link For InLineEdit.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Edit Column Edit Text That Displays On The Edit Link For InLineEdit.")]
   public string EditColumnEditText
   {
    get
    {
     return this.strEditColumnEditText;
    }
    set
    {
     this.strEditColumnEditText = value;
    }
   }
   /// <summary>
   /// Edit Column Header Text That Displays On The Edit Link Header For InLineEdit.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Edit Column Edit Text That Displays On The Edit Link Header For InLineEdit.")]
   public string EditColumnHeaderText
   {
    get
    {
     return this.strEditColumnHeaderText;
    }
    set
    {
     this.strEditColumnHeaderText = value;
    }
   }
   /// <summary>
   /// Edit Column Update Text That Displays On The Edit Link For InLineEdit.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Edit Column Update Text That Displays On The Edit Link For InLineEdit.")]
   public string EditColumnUpdateText
   {
    get
    {
     return this.strEditColumnUpdateText;
    }
    set
    {
     this.strEditColumnUpdateText = value;
    }
   }
   /// <summary>
   /// Edit Column Cancel Text That Displays On The Edit Link For InLineEdit.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Edit Column Cancel Text That Displays On The Edit Link For InLineEdit.")]
   public string EditColumnCancelText
   {
    get
    {
     return this.strEditColumnCancelText;
    }
    set
    {
     this.strEditColumnCancelText = value;
    }
   }  
   /// <summary>
   /// Delete Column Delete Text That Displays On The Delete Link.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Delete Column Delete Text That Displays On The Delete Link.")]
   public string DeleteColumnDeleteText
   {
    get
    {
     return this.strDeleteColumnDeleteText;
    }
    set
    {
     this.strDeleteColumnDeleteText = value;
    }
   }
   /// <summary>
   /// Delete Column Header Text That Displays On The Delete Link.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Delete Column Header Text That Displays On The Delete Link.")]
   public string DeleteColumnHeaderText
   {
    get
    {
     return this.strDeleteColumnHeaderText;
    }
    set
    {
     this.strDeleteColumnHeaderText = value;
    }
   }
   /// <summary>
   /// Status Property Of Where there To Render The Whole DataRow With Each Item Attribute On The Client Side In XML.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Status Property Of Wherethere To Render The Whole DataRow With Each Item Attribute On The Client Side In XML.")]
   public bool PersistDataRowInGridItem
   {
    get
    {
     return this.blnPersistDataRowInGridItem;
    }
    set
    {
     this.blnPersistDataRowInGridItem = value;
    }
   }
   /// <summary>
   /// Stores The Client Side Function Name Which Returns Whole DataRow In XML.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Stores The Client Side Function Name Which Returns Whole DataRow In XML.")]
   public string ClientSideFunctionForDataRow
   {
    get
    {
     return this.strClientSideFunctionForDataRow;
    }
   }  
   /// <summary>
   /// Elipse Button Default Text Which Appears On The HTML Button.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Elipse Button Default Text Which Appears On The HTML Button.")]
   public string ElipseButtonDefaultText
   {
    get
    {
     return this.strElipseButtonDefaultText;
    }
    set
    {
     this.strElipseButtonDefaultText = value;
    }
   }
   /// <summary>
   /// Client Side Function Name Which Returns TextBox Control Of ElipseButton.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Client Side Function Name Which Returns TextBox Control Of ElipseButton.")]
   public string ElipseButtonClientSideFunction
   {
    get
    {
     return this.strElipseButtonClientSideFunction;
    }
   }
   /// <summary>
   /// ReadOnlyTextBoxCss i.e. StyleSheet Name.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Stores The ReadOnlyTextBoxCss i.e. StyleSheet Name.")]
   public string ReadOnlyTextBoxCss
   {
    get
    {
     return this.strReadOnlyTextBoxCss;
    }
    set
    {
     this.strReadOnlyTextBoxCss = value;
    }
   }
   /// <summary>
   /// Location Where To Render The Edit Link Column On ClientSide For InLine Edit.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Location Where To Render The Edit Link Column On ClientSide For InLine Edit.")]
   public linkcolumntype EditLinkColumnOrdinal
   {
    get
    {
     if(this.intEditLinkColumnOrdinal == INT_ZERO)
     {
      return linkcolumntype.FirstColumn; 
     }
     else
     {
      return linkcolumntype.SecondColumn;
     }
    }
    set
    {
     if(value == linkcolumntype.FirstColumn && DeleteLinkColumnOrdinal != linkcolumntype.FirstColumn)
     {
      this.intEditLinkColumnOrdinal = INT_ZERO; 
     }
     else
     {
      this.intEditLinkColumnOrdinal = INT_ONE;
     }     
    }
   }
   /// <summary>
   /// Location Where To Render The Delete Link Column On ClientSide For InLine Edit.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Location Where To Render The Delete Link Column On ClientSide For InLine Edit.")]
   public linkcolumntype DeleteLinkColumnOrdinal
   {
    get
    {
     if(this.intDeleteLinkColumnOrdinal == INT_ZERO)
     {
      return linkcolumntype.FirstColumn;
     }
     else
     {
      return linkcolumntype.SecondColumn;
     }
    }
    set
    {
     if(value == linkcolumntype.FirstColumn)
     {
      this.intDeleteLinkColumnOrdinal = INT_ZERO; 
     }
     else
     {
      this.intDeleteLinkColumnOrdinal = INT_ONE;
     }
    }
   }
   /// <summary>
   /// Type Of Caption For Edit & Delete Link i.e. Text or Graphic.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Type Of Caption For Edit & Delete Link i.e. Text or Graphic.")]
   public captiontype CaptionControlEditDeleteLink
   {
    get
   {
    return this.captiontypeCaptionControlEditDeleteLink;
   }
    set
   {
    this.captiontypeCaptionControlEditDeleteLink = value;
   }
   }
   /// <summary>
   /// Edit Link Image Location i.e. URL.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Edit Link Image Location i.e. URL.")]
   public string EditLinkImageLocation
   {
    get
    {
     return this.strEditLinkImageLocation;
    }
    set
    {
     this.strEditLinkImageLocation = value;
    }
   }
   /// <summary>
   /// Delete Link Image Location i.e. URL.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Delete Link Image Location i.e. URL.")]
   public string DeleteLinkImageLocation
   {
    get
    {
     return this.strDeleteLinkImageLocation;
    }
    set
    {
     this.strDeleteLinkImageLocation = value;
    }
   }
   /// <summary>
   /// Apply Link Image Location i.e. URL.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Apply Link Image Location i.e URL.")]
   public string ApplyLinkImageLocation
   {
    get
    {
     return this.strApplyLinkImageLocation;
    }
    set
    {
     this.strApplyLinkImageLocation = value;
    }
   }
   /// <summary>
   /// Cancel Link Image Location i.e. URL.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Cancel Link Image Location i.e. URL.")]
   public string CancelLinkImageLocation
   {
    get
    {
     return this.strCancelLinkImageLocation;
    }
    set
    {
     this.strCancelLinkImageLocation = value;
    }
   }
   /// <summary>
   /// Item Cell Wrap Used for Formatting The Text on The Client.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Item Cell Wrap Used for Formatting The Text on The Client.")]
   public bool ItemCellWrap
   {
    get
    {
     return this.blnItemCellWrap;
    }
    set
    {
     this.blnItemCellWrap = value;
    }
   }
   /// <summary>
   /// DateControl TextBox Type i.e Editable or ReadOnly.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("DateControl TextBox Type i.e Editable or ReadOnly.")]
   public textboxtype DateControlTextBoxType
   {
    get
    {
     return this.textboxtypeDateControl;
    }
    set
    {
     this.textboxtypeDateControl = value;
    }
   }
   /// <summary>
   /// ElipseButtonControl TextBox Type i.e Editable or ReadOnly.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("ElipseButtonControl TextBox Type i.e Editable or ReadOnly.")]
   public textboxtype ElipseButtonControlTextBoxType
   {
    get
    {
     return this.textboxtypeElipseButtonControl;
    }
    set
    {
     this.textboxtypeElipseButtonControl = value;
    }
   }
   /// <summary>
   /// Text Message If There Are No DataRows In The Datasource's Bounded DataMember.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Text Message If There Are No DataRows In The Datasource's Bounded DataMember.")]
   public string NoRecordMessage
   {
    get
    {
     return this.strNoRecordMessage;
    }
    set
    {
     this.strNoRecordMessage = value;
    }
   }
   /// <summary>
   /// Checkbox State To Be Maintained Across Page, Single Page or NoPage.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Checkbox State To Be Maintained Across Page, Single Page or NoPage.")]
   public checkboxstate CheckBoxState
   {
    get
    {
     return this.checkboxstateCheckBoxState;    
    }
    set
    {
     this.checkboxstateCheckBoxState = value;
    }
   }
   /// <summary>
   /// DataColumn Name Of Type Boolean Of Which To Persistist Data.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("Checkbox State DataColumnName.")]
   public string CheckBoxStateColumnName
   {
    get
    {
     return this.strCheckBoxStateColumnName;
    }
    set
    {
     this.strCheckBoxStateColumnName = value;
    }
   }
   /// <summary>
   /// DataSet Of Checked Records Of One Page Or Across Pages.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("DataSet Of Checked Records Of One Page Or Across Pages.")]
   public DataSet CheckBoxStateData
   {
    get
    {
     //
     this.CheckBoxStateDataCollection();
     //
     return this.dsCheckBoxState;
    }
   }
   /// <summary>
   /// ClientSide Function Name For CheckBoxState Record CountDataSet Of Checked Records Of One Page Or Across Pages.
   /// </summary>
   [Category("AlladinDataGrid"), DefaultValue(""), Description("DataSet Of Checked Records Of One Page Or Across Pages.")]
   public string CheckBoxStateRecordCountClientSideFunctionName
   {
    get
    {
     return this.strClientSideFunctionForCheckBoxStateRecordCount;
    }
   }
  #endregion
  #region Public Methods  
   /// <summary>
   /// This Method Returns A DataSet From The DataGrids Item Cells With The Same Schema As The Binded DataMember.
   /// </summary>
   /// <returns>Dataset With The Updated Values From The DataGrids Items Cells Controls</returns>
   public DataSet UpdatedDataSetFromDataGrid()
   {
    this.UpdateDataSetFromDataGrid();   
    return this.dsGridData;
   }
  #endregion
  #region Overidable Events, Events & Methods Declaration
  /// <summary>
  /// Constructure of the class That Registers The DataGrids Default Events To Be Handled By This Class And Triggers AlladinException Event.
  /// </summary>
  public AlladinDataGrid()
  {
   //try
   //{
    #region Registering DataGrid Event That Are Handled By AlladinDataGrid Class
     SortCommand +=new DataGridSortCommandEventHandler(AlladinDataGrid_SortCommand);
     DataBinding +=new EventHandler(AlladinDataGrid_DataBinding);
     PreRender +=new EventHandler(AlladinDataGrid_PreRender);
     PageIndexChanged +=new DataGridPageChangedEventHandler(AlladinDataGrid_PageIndexChanged);
     EditCommand +=new DataGridCommandEventHandler(AlladinDataGrid_EditCommand);
     DeleteCommand +=new DataGridCommandEventHandler(AlladinDataGrid_DeleteCommand);
     UpdateCommand +=new DataGridCommandEventHandler(AlladinDataGrid_UpdateCommand);
     CancelCommand +=new DataGridCommandEventHandler(AlladinDataGrid_CancelCommand);
     ItemCreated +=new DataGridItemEventHandler(AlladinDataGrid_ItemCreated);
     ItemCommand +=new DataGridCommandEventHandler(AlladinDataGrid_ItemCommand);
    #endregion
   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }
  /// <summary>
  /// This Method Overides the DataGrid Init Event And Registers Data From Hidden Controls, ConfigFile And
  /// The Hidden Controls ClientId.
  /// </summary>
  /// <param name="e"></param>
  protected override void OnInit(EventArgs e)
  {
   //try
   //{
   #region Configuration Information For Style Sheets Of Template Columns
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[CSSCLASS], null))
    {
     this.CssClass = ConfigurationSettings.AppSettings[CSSCLASS];
    }
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[HEADERCSSCLASS], null))
    {
     this.HeaderStyle.CssClass = ConfigurationSettings.AppSettings[HEADERCSSCLASS];
    }
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[ITEMCSSCLASS], null))
    {
     this.ItemStyle.CssClass = ConfigurationSettings.AppSettings[ITEMCSSCLASS];
    }    
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[ALTERNATINGITEMCSSCLASS], null))
    {
     this.AlternatingItemStyle.CssClass = ConfigurationSettings.AppSettings[ALTERNATINGITEMCSSCLASS];
    }
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[SELECTEDITEMCSSCLASS], null))
    {
     this.SelectedItemStyle.CssClass = ConfigurationSettings.AppSettings[SELECTEDITEMCSSCLASS];
    }    
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[FOOTERCSSCLASS], null))
    {
     this.FooterStyle.CssClass = ConfigurationSettings.AppSettings[FOOTERCSSCLASS];
    }
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[PAGERCSSCLASS], null))
    {
     this.PagerStyle.CssClass = ConfigurationSettings.AppSettings[PAGERCSSCLASS];
    }
    //
    if(!object.Equals(ConfigurationSettings.AppSettings[PAGESIZE], null))
    {
     this.PageSize = int.Parse(ConfigurationSettings.AppSettings[PAGESIZE]);
    }
    if(!object.Equals(ConfigurationSettings.AppSettings[PAGEMODEWEBCONFIGKEY], null))
    {
     this.PagerStyle.Mode = (PagerMode) TypeDescriptor.GetConverter(this.PagerStyle.Mode).ConvertFrom(ConfigurationSettings.AppSettings[PAGEMODEWEBCONFIGKEY]);
    }
    if(!object.Equals(ConfigurationSettings.AppSettings[PAGEPOSITIONWEBCONFIGKEY], null))
    {
     this.PagerStyle.Position = (PagerPosition) TypeDescriptor.GetConverter(this.PagerStyle.Position).ConvertFrom(ConfigurationSettings.AppSettings[PAGEPOSITIONWEBCONFIGKEY]);
    }
    if(!object.Equals(ConfigurationSettings.AppSettings[BORDERCOLORWEBCONFIGKEY], null))
    {
     this.BorderColor = (Color) TypeDescriptor.GetConverter(this.BorderColor).ConvertFrom(ConfigurationSettings.AppSettings[BORDERCOLORWEBCONFIGKEY]);
    }
   #endregion
   #region Configuration Information For Item Cell Alignments & Texts, Date Formats And Validator Control Message & Values
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[HORIZONTALALIGNBOOL], null))
   {
    this.horizontalalignBoolean = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[HORIZONTALALIGNBOOL], this.horizontalalignBoolean);
   }     
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[HORIZONTALALIGNDATATIME], null))
   {
    this.horizontalalignDateTime = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[HORIZONTALALIGNDATATIME], this.horizontalalignDateTime);
   }    
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[HORIZONTALALIGNSTRING], null))
   {
    this.horizontalalignString = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[HORIZONTALALIGNSTRING], this.horizontalalignString);
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[HORIZONTALALIGNNUMERIC], null))
   {
    this.horizontalalignNumeric = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[HORIZONTALALIGNNUMERIC], this.horizontalalignNumeric);
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[VERTICALALIGNBOOL], null))
   {
    this.verticalalignBoolean = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[VERTICALALIGNBOOL], this.verticalalignBoolean);
   }     
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[VERTICALALIGNDATATIME], null))
   {
    this.verticalalignDateTime = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[VERTICALALIGNDATATIME], this.verticalalignDateTime);
   }    
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[VERTICALALIGNSTRING], null))
   {
    this.verticalalignString = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[VERTICALALIGNSTRING], this.verticalalignString);
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[VERTICALALIGNNUMERIC], null))
   {
    this.verticalalignNumeric = this.ConvertStringToAlign(ConfigurationSettings.AppSettings[VERTICALALIGNNUMERIC], this.verticalalignNumeric);
   }    
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[DATETIMEFORMAT], null))
   {
    this.strDateFormat = ConfigurationSettings.AppSettings[DATETIMEFORMAT];
   }    
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[DROPDOWNLISTDEFAULTTEXTSTRING], null))
   {
    this.strDropDownListDefaultTextField = ConfigurationSettings.AppSettings[DROPDOWNLISTDEFAULTTEXTSTRING];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[REQUIREDFIELDVALIDATORDEFAULTMESSAGEKEY], null))
   {
    this.strRequiredFieldValidatorDefaultMessage = ConfigurationSettings.AppSettings[REQUIREDFIELDVALIDATORDEFAULTMESSAGEKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTMESSAGEKEY], null))
   {
    this.strRangeValidatorDefaultMessage = ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTMESSAGEKEY];
   }   
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTDECIMALMINVALUEKEY], null))
   {
    this.strRangeValidatorDefaultDecimalMinValue = ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTDECIMALMINVALUEKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTDECIMALMAXVALUEKEY], null))
   {
    this.strRangeValidatorDefaultDecimalMaxValue = ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTDECIMALMAXVALUEKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTINTEGERMINVALUEKEY], null))
   {
    this.strRangeValidatorDefaultIntegerMinValue = ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTINTEGERMINVALUEKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTINTEGERMAXVALUEKEY], null))
   {
    this.strRangeValidatorDefaultIntegerMaxValue = ConfigurationSettings.AppSettings[RANGEVALIDATORDEFAULTINTEGERMAXVALUEKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[EDITCOLUMNEDITTEXTKEY], null))
   {
    this.strEditColumnEditText = ConfigurationSettings.AppSettings[EDITCOLUMNEDITTEXTKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[EDITCOLUMNUPDATETEXTKEY], null))
   {
    this.strEditColumnUpdateText = ConfigurationSettings.AppSettings[EDITCOLUMNUPDATETEXTKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[EDITCOLUMNCANCELTEXTKEY], null))
   {
    this.strEditColumnCancelText = ConfigurationSettings.AppSettings[EDITCOLUMNCANCELTEXTKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[EDITCOLUMNHEADERTEXTKEY], null))
   {
    this.strEditColumnHeaderText = ConfigurationSettings.AppSettings[EDITCOLUMNHEADERTEXTKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[DELETECOLUMNDELETETEXTKEY], null))
   {
    this.strDeleteColumnDeleteText = ConfigurationSettings.AppSettings[DELETECOLUMNDELETETEXTKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[DELETECOLUMNHEADERTEXTKEY], null))
   {
    this.strDeleteColumnHeaderText = ConfigurationSettings.AppSettings[DELETECOLUMNHEADERTEXTKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[ITEMREADONLYCSSCLASSKEY], null))
   {
    this.strItemReadOnlyCssClass = ConfigurationSettings.AppSettings[ITEMREADONLYCSSCLASSKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[ELIPSEBUTTONDEFAULTTEXTKEY], null))
   {
    this.strElipseButtonDefaultText = ConfigurationSettings.AppSettings[ELIPSEBUTTONDEFAULTTEXTKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[READONLYTEXTBOXKEY], null))
   {
    this.strReadOnlyTextBoxCss = ConfigurationSettings.AppSettings[READONLYTEXTBOXKEY];
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[ITEMCELLWRAPKEY], null))
   {
    this.blnItemCellWrap = bool.Parse(ConfigurationSettings.AppSettings[ITEMCELLWRAPKEY]);
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[DATECONTROLTEXTBOXTYPEKEY], null))
   {
    this.textboxtypeDateControl = (textboxtype) TypeDescriptor.GetConverter(this.textboxtypeDateControl).ConvertFrom(ConfigurationSettings.AppSettings[DATECONTROLTEXTBOXTYPEKEY]);
   }
   //
   if(!object.Equals(ConfigurationSettings.AppSettings[ELIPSEBUTTONTEXTBOXTYPEKEY], null))
   {
    this.textboxtypeElipseButtonControl = (textboxtype) TypeDescriptor.GetConverter(this.textboxtypeElipseButtonControl).ConvertFrom(ConfigurationSettings.AppSettings[ELIPSEBUTTONTEXTBOXTYPEKEY]);
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[NORECORDMESSAGEKEY], null))
   {
    this.strNoRecordMessage = ConfigurationSettings.AppSettings[NORECORDMESSAGEKEY];
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[DELETETYPEWEBCONFIGKEY], null))
   {
    this.deletetypeDeleteType = (deletetype) TypeDescriptor.GetConverter(this.deletetypeDeleteType).ConvertFrom(ConfigurationSettings.AppSettings[DELETETYPEWEBCONFIGKEY]);  
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[DELETECONFIRMATIONMESSAGEWEBCONFIGKEY], null))
   {
    this.strDeleteConfirmationMessage = ConfigurationSettings.AppSettings[DELETECONFIRMATIONMESSAGEWEBCONFIGKEY];
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[CANCELTYPEWEBCONFIGKEY], null))
   {
    this.canceltypeCancelType = (canceltype) TypeDescriptor.GetConverter(this.canceltypeCancelType).ConvertFrom(ConfigurationSettings.AppSettings[CANCELTYPEWEBCONFIGKEY]);  
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[CANCELCONFIRMATIONMESSAGEWEBCONFIGKEY], null))
   {
    this.strCancelConfirmationMessage = ConfigurationSettings.AppSettings[CANCELCONFIRMATIONMESSAGEWEBCONFIGKEY];
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[DATEPICKERIMAGELOCATIONWEBCONFIGKEY], null))
   {
    this.strDatePickerImageLocation = ConfigurationSettings.AppSettings[DATEPICKERIMAGELOCATIONWEBCONFIGKEY];
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[CAPTIONCONTROLEDITDELETELINKWEBCONFIGKEY], null))
   {
    this.captiontypeCaptionControlEditDeleteLink = (captiontype) TypeDescriptor.GetConverter(this.captiontypeCaptionControlEditDeleteLink).ConvertFrom(ConfigurationSettings.AppSettings[CAPTIONCONTROLEDITDELETELINKWEBCONFIGKEY]);  
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[EDITLINKIMAGELOCATIONWEBCONFIGKEY], null))
   {
    this.strEditLinkImageLocation = ConfigurationSettings.AppSettings[EDITLINKIMAGELOCATIONWEBCONFIGKEY];
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[DELETELINKIMAGELOCATIONWEBCONFIGKEY], null))
   {
    this.strDeleteLinkImageLocation = ConfigurationSettings.AppSettings[DELETELINKIMAGELOCATIONWEBCONFIGKEY];
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[APPLYLINKIMAGELOCATIONWEBCONFIGKEY], null))
   {
    this.strApplyLinkImageLocation = ConfigurationSettings.AppSettings[APPLYLINKIMAGELOCATIONWEBCONFIGKEY];
   }
   if(!object.Equals(ConfigurationSettings.AppSettings[CANCELLINKIMAGELOCATIONWEBCONFIGKEY], null))
   {
    this.strCancelLinkImageLocation = ConfigurationSettings.AppSettings[CANCELLINKIMAGELOCATIONWEBCONFIGKEY];
   }   
   #region Setting EditLink Column Ordinal
   //Setting EditLink Column Ordinal
   if(!object.Equals(ConfigurationSettings.AppSettings[EDITLINKCOLUMNKEY], null))
   {
    if(linkcolumntype.FirstColumn.ToString() == ConfigurationSettings.AppSettings[EDITLINKCOLUMNKEY].ToString())
    {
     this.intEditLinkColumnOrdinal = INT_ZERO; 
    }
    else
    {
     this.intEditLinkColumnOrdinal = INT_ONE; 
    }
   }   
   #endregion
   #region Setting DeleteLink Column Ordinal
   //Setting DeleteLink Column Ordinal
   if(!object.Equals(ConfigurationSettings.AppSettings[DELETELINKCOLUMNKEY], null))
   {
    if(linkcolumntype.FirstColumn.ToString() == ConfigurationSettings.AppSettings[DELETELINKCOLUMNKEY].ToString())
    {
     this.intDeleteLinkColumnOrdinal = INT_ZERO; 
    }
    else
    {
     this.intDeleteLinkColumnOrdinal = INT_ONE; 
    }      
   }        
   #endregion
   #endregion
   #region Setting The Grid & HiddenControls Name That Render On CliendSide Or Request.Form Values
   //
   //if(object.Equals(this.NamingContainer.ClientID, null))
   //{
                //this.strDataGridClientId = this.ClientID + COLON;
                this.strDataGridClientId = this.ClientID + this.ClientIDSeparator.ToString();
   //}
   //else
   //{
    //this.strDataGridClientId = this.NamingContainer.ClientID + COLON + this.ID + COLON;
            //    this.strDataGridClientId = this.NamingContainer.ClientID + this.ClientIDSeparator.ToString() + this.ID + this.ClientIDSeparator.ToString();    
   /////}
   //
   // this.strDataGridClientIdForJavaScript = this.strDataGridClientId.Replace(COLON, UNDERSCORE);

 

   //
   if(this.AllowSorting)
   {
    //
                if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSORTDIRECTIONID], null))
    {
                    this.strSortDirection = HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSORTDIRECTIONID];
    }
    //
                if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSORTEXPRESSIONID], null))
    {
                    this.strSortExpression = HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSORTEXPRESSIONID];
    }
               


   }
   //
            if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENDATAMEMBERNAME], null))
   {
                this.strDataMemberName = HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENDATAMEMBERNAME];
   }
   //
   if(!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSCHEMA], null))
   {
    this.dsGridData = this.DeserializeDataSchema(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSCHEMA], false);
    this.strSchemaXML = HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSCHEMA];
   }    
   //
            if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENDATACOLUMNEXTENDEDPROPERTYSCHEMA], null))
   {

                this.DeSerializeDataColumnsExtendedProperties(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENDATACOLUMNEXTENDEDPROPERTYSCHEMA]);
                this.strDataColumnExtendedPropertySchema = HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENDATACOLUMNEXTENDEDPROPERTYSCHEMA];
    //this.strDataColumnExtendedPropertySchema = this.SerializeDataColumnsExtendedProperties(); 
   }    
   //
            if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENSCHEMA], null))
   {
    if(this.dsGridData != null)
    {
     this.SetColumnTemplate();
    }
    else
    {
     this.RaiseException(new ArgumentNullException("DataSet", " Cannot Be Serialized"));
    }      
   }
   //
   this.strHiddenSelectedRowNumber = this.strDataGridClientId + HIDDENROWNUMBER;
   //
            if (!object.Equals(HttpContext.Current.Request.Form[this.strHiddenSelectedRowNumber.Replace(UNDERSCORE, DOLLAR)], null))
   {
                this.intHiddenSelectedRowNumber = int.Parse(HttpContext.Current.Request.Form[this.strHiddenSelectedRowNumber.Replace(UNDERSCORE, DOLLAR)]);
   }
   //
            this.strHiddenSelectedRowNumber = this.strHiddenSelectedRowNumber.Replace(UNDERSCORE, DOLLAR).Replace(COLON, UNDERSCORE);
   //
            this.strHiddenEditEvent = ((string)(this.strDataGridClientId + HIDDENEDITEVENT)).Replace(UNDERSCORE, DOLLAR).Replace(COLON, UNDERSCORE);
   //
            this.strHiddenDeleteEvent = ((string)(this.strDataGridClientId + HIDDENDELETEEVENT)).Replace(UNDERSCORE, DOLLAR).Replace(COLON, UNDERSCORE);
   //
   this.strDeleteClientFunctionName = this.strDataGridClientIdForJavaScript + DELETEMEFUNCTIONNAME;
   //
   this.strEditClientFunctionName = this.strDataGridClientIdForJavaScript + EDITMEFUNCTIONNAME; 
   //
   this.strSelectedRowNoClientFunctionName = this.strDataGridClientIdForJavaScript + SELECTEDROWNOFUNCTIONNAME;
   //
   this.strSelectedRowIdClientFunctionName = this.strDataGridClientIdForJavaScript + SELECTEDROWIDFUNCTIONNAME;
   //
   this.strClientSideFunctionForCheckBoxState = this.strDataGridClientIdForJavaScript + CHECKBOXSTATEFUNCTIONNAME;
   //
   this.strClientSideFunctionForCheckBoxStateRecordCount = this.strDataGridClientIdForJavaScript + CHECKBOXSTATERECORDCOUNTFUNCTIONNAME;
   //
   this.strClientSideFunctionForCheckBoxStateHeaderCheck = this.strDataGridClientIdForJavaScript + CHECKBOXSTATEHEADERCHECKFUNCTIONNAME;
   //
            this.strHiddenOldStyleControl = ((string)(this.strDataGridClientId + HIDDENOLDSTYLECONTROL)).Replace(UNDERSCORE, DOLLAR).Replace(COLON, UNDERSCORE);
   //
   this.strClientSideFunctionForDataRow = this.strDataGridClientIdForJavaScript + DATAROWITEMCLIENTFUNCTION;
   //
   this.strElipseButtonClientSideFunction =  this.strDataGridClientIdForJavaScript + ELIPSEBUTTONCLIENTSIDEFUNCTION;
   //
   this.strHiddenCommandName = this.strDataGridClientIdForJavaScript + HIDDENCOMMANDNAME;
   //
            if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENCOMMANDNAME], null))
   {
                this.strCommandName = HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENCOMMANDNAME];
   } 
   //
            if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENTOTALNUMBERPAGES], null))
   {
                this.decimalTotalNumberOfPages = int.Parse(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENTOTALNUMBERPAGES]);
   }
   //
            if (!object.Equals(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENCHECKBOXSTATEDATA], null))
   {
                this.dsCheckBoxState = this.DeserializeDataSchema(HttpContext.Current.Request.Form[this.strDataGridClientId.Replace(UNDERSCORE, DOLLAR) + HIDDENCHECKBOXSTATEDATA], true);
   }
   #endregion

   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }
  /// <summary>
  /// This Event Performs The Sorting Of the DataGrid And Fires the AlladinsDataBinding & AlladinException Event
  /// </summary>
  /// <param name="source">Object That Fired The Event</param>
  /// <param name="e">Cells Data & Control</param>
  private void AlladinDataGrid_SortCommand(object source, DataGridSortCommandEventArgs e)
  {
   //try
   //{
    //
    this.CheckBoxStateDataCollection();
    //
    this.strSortExpression = e.SortExpression;
    //
    if(this.strSortDirection == SORTDESC)
    {
     this.strSortDirection = SORTASC;
    }
    else
    {
     this.strSortDirection = SORTDESC;
    }
    //
    this.RaiseDataGridBinding();
   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }
  /// <summary>
  /// This Event Creates The default ItemTemplate Columns Based on the DataSource Which must Be A DataSet And Triggers AlladinException Event. 
  /// </summary>
  /// <param name="sender">Object That Triggered The Event</param>
  /// <param name="e"></param>
  private void AlladinDataGrid_DataBinding(object sender, EventArgs e)
  {
   try
   {
    //    
    if (this.DataSource != null && this.DataSource is DataSet)
    {
     //
     this.strSchemaXML = this.SerializeDataSchema((object) ((DataSet) this.DataSource).GetXmlSchema());
     //
     this.dsGridData = (DataSet) this.DataSource;
     // 
     this.strDataMemberName = this.DataMember;
     //
     if(this.dsGridData.Tables[this.strDataMemberName].Rows.Count >= this.PageSize)
     {
      this.decimalTotalNumberOfPages = this.dsGridData.Tables[this.strDataMemberName].Rows.Count / this.PageSize;
     }
     //
     this.DataSource = ((DataSet) this.DataSource).Tables[this.DataMember.ToString()].DefaultView;
     //
     this.strDataColumnExtendedPropertySchema = this.SerializeDataColumnsExtendedProperties();
     //
     this.SetColumnTemplate();
     //Setting The Sorting Properties Option If Sorting Is Enabled
     if(this.AllowSorting)
     {
      if(!object.Equals(this.strSortExpression, null))
      {
       if(INT_ZERO < this.strSortExpression.Length) 
       {
        ((DataView)this.DataSource).Sort = this.strSortExpression + this.strSortDirection;
       }      
      }
     }
    }
   }
   catch(Exception exception)
   {
    this.RaiseException(exception);
   }
  }
  /// <summary>
  /// This Event Registers ClientSide Function & Adds Hidden Controls To The DataGrid Control Collection
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void AlladinDataGrid_PreRender(object sender, EventArgs e)
  {
   try
   {
    //
    if(this.dsGridData.Tables.Count == INT_ZERO)
    {
     return;
    }
    //
    string strCurrentRow;
    //
    Control control;
    #region Formats The Item & ItemCells Based ReadOnlyItemCell Member Variable
     this.FormatGridItems();
    #endregion
    #region Adding The Sorted Expression & Sort Direction To The Hidden Control
     //Adding The Sorted Expression & Sort Direction To The Hidden Control
     if(this.AllowSorting)
     {
      //Creating A Hidden Control For Maintaining State Of SortDirection
      HtmlInputHidden hidSortDirection  = new HtmlInputHidden();
      hidSortDirection.ID = HIDDENSORTDIRECTIONID;
      hidSortDirection.Value = this.strSortDirection; 
      //Creating A Hidden Control For Maintaining State Of SortExpression
      HtmlInputHidden hidSortExpression = new HtmlInputHidden();
      hidSortExpression.ID = HIDDENSORTEXPRESSIONID;
      hidSortExpression.Value = this.strSortExpression; 
      //Adding The Hidden Control To The DataGrid
      this.Controls.Add(hidSortExpression);
      this.Controls.Add(hidSortDirection);
     }
    #endregion
    #region Adding The XMLSchema To The Hidden Control
     //Adding The XMLSchema To The Hidden Control 
     if(INT_ZERO < this.strSchemaXML.Length)
     {
      //
      HtmlInputHidden hidSchema = new HtmlInputHidden();
      hidSchema.ID = HIDDENSCHEMA;
      hidSchema.Value = this.strSchemaXML;   
      this.Controls.Add(hidSchema);
      //
      //
      HtmlInputHidden hidDataMember = new HtmlInputHidden();
      hidDataMember.ID = HIDDENDATAMEMBERNAME;
      hidDataMember.Value = this.DataMember;   
      this.Controls.Add(hidDataMember);
     }
    #endregion
    #region Adding CommandSource Hidden Control
     //
     HtmlInputHidden hidCommandSource = new HtmlInputHidden();
     hidCommandSource.ID = HIDDENCOMMANDNAME;
     //hidCommandSource.Value = this.strCommandSource;   
     this.Controls.Add(hidCommandSource);
    #endregion
    #region Adding The Selected Row Number To Hidden Control
     //Adding The Selected Row Number To Hidden Control
     HtmlInputHidden hidRowNo = new HtmlInputHidden();
     hidRowNo.ID    = HIDDENROWNUMBER;
     hidRowNo.Value = this.intHiddenSelectedRowNumber.ToString();   
     this.Controls.Add(hidRowNo);
    #endregion
    #region Adding Total Number Of Pages To Hidden Control
     //
     HtmlInputHidden hidTotalNumberOfPages = new HtmlInputHidden();
     hidTotalNumberOfPages.ID = HIDDENTOTALNUMBERPAGES;
     hidTotalNumberOfPages.Value = this.decimalTotalNumberOfPages.ToString();
     this.Controls.Add(hidTotalNumberOfPages);
    #endregion
    #region Adding CheckBoxStateData To The Hidden Control
     //
     if(this.checkboxstateCheckBoxState == checkboxstate.StateAcrossPages)
     {
      //
      HtmlInputHidden hidCheckBoxStateData = new HtmlInputHidden();
      hidCheckBoxStateData.ID = HIDDENCHECKBOXSTATEDATA;
      hidCheckBoxStateData.Value = this.SerializeDataSchema((object)this.dsCheckBoxState.GetXml());
      //hidCheckBoxStateData.Attributes(DATAROWITEMATTRIBUTE, this.dsCheckBoxState.GetXml());
      this.Controls.Add(hidCheckBoxStateData);
     }
    #endregion
    #region Adding The DataColumnExtendedPropertySchema To The Hidden Control
     if(!object.Equals(this.strDataColumnExtendedPropertySchema, null))
     {
      if(this.strDataColumnExtendedPropertySchema.Length > INT_ZERO)
      {
       //
       HtmlInputHidden hidDataColumnExtendedPropertySchema = new HtmlInputHidden();
       hidDataColumnExtendedPropertySchema.ID = HIDDENDATACOLUMNEXTENDEDPROPERTYSCHEMA;
       hidDataColumnExtendedPropertySchema.Value = this.strDataColumnExtendedPropertySchema;   
       this.Controls.Add(hidDataColumnExtendedPropertySchema);            
      }     
     }

    #endregion
    //Adding ClientSide Scripts
    this.RegistetrClientScripts();
    //
    if(this.intHiddenSelectedRowNumber == INT_NEGATIVE_ONE)
    {
     //
     if(this.AllowPaging)
     {
      strCurrentRow = INT_TWO.ToString();
     }
     else
     {
      strCurrentRow = INT_ONE.ToString();
     }
    }
    else
    {
     strCurrentRow = this.intHiddenSelectedRowNumber.ToString();
    }
    #region Adding EditEvent & DeleteEvent To Hidden Controls
     //
     //
     HtmlInputHidden hidEditEvent = new HtmlInputHidden();
     hidEditEvent.ID    = HIDDENEDITEVENT;
     if(!object.Equals(HttpContext.Current.Request.Form[this.strHiddenEditEvent.Replace(UNDERSCORE, COLON)], null))
     {
      hidEditEvent.Value = HttpContext.Current.Request.Form[this.strHiddenEditEvent.Replace(UNDERSCORE, COLON)];
     }
     else
     {
      if(this.captiontypeCaptionControlEditDeleteLink == captiontype.Graphics)
      {
       if(this.EditItemIndex != this.Items[INT_ZERO].ItemIndex)
       {
        hidEditEvent.Value = this.DefaultPostBackClientSideFunction(INT_NEGATIVE_ONE, this.Items[INT_ZERO].Cells[this.intEditLinkColumnOrdinal].Controls.Count, false);
       }
      }
      else
      {
       hidEditEvent.Value = this.DefaultPostBackClientSideFunction(INT_NEGATIVE_ONE, this.intEditLinkColumnOrdinal, false);
      }
      
     }
     this.Controls.Add(hidEditEvent);
     //
     HtmlInputHidden hidDeleteEvent = new HtmlInputHidden();
     hidDeleteEvent.ID    = HIDDENDELETEEVENT;
     if(!object.Equals(HttpContext.Current.Request.Form[this.strHiddenDeleteEvent.Replace(UNDERSCORE, COLON)], null))
     {
      hidDeleteEvent.Value = HttpContext.Current.Request.Form[this.strHiddenDeleteEvent.Replace(UNDERSCORE, COLON)]; 
     }
     else
     {
      if(this.captiontypeCaptionControlEditDeleteLink == captiontype.Graphics)
      {
       if(this.EditItemIndex != this.Items[INT_ZERO].ItemIndex)
       {
        hidDeleteEvent.Value = this.DefaultPostBackClientSideFunction(INT_NEGATIVE_ONE, this.Items[INT_ZERO].Cells[this.intDeleteLinkColumnOrdinal].Controls.Count + INT_ONE, false);
       }       
      }
      else
      {
       hidDeleteEvent.Value = this.DefaultPostBackClientSideFunction(INT_NEGATIVE_ONE, this.intDeleteLinkColumnOrdinal, false);
      }
     }
     this.Controls.Add(hidDeleteEvent);
    #endregion
    #region Adding OldStyleSheet To HiddenControl
     //
     HtmlInputHidden hidOldStyleControl = new HtmlInputHidden();
     hidOldStyleControl.ID    = HIDDENOLDSTYLECONTROL;
     if(!object.Equals(HttpContext.Current.Request.Form[this.strHiddenOldStyleControl.Replace(UNDERSCORE, COLON)], null))
     {
      hidOldStyleControl.Value = HttpContext.Current.Request.Form[this.strHiddenOldStyleControl.Replace(UNDERSCORE, COLON)]; 
     }    
     this.Controls.Add(hidOldStyleControl);
    #endregion
    #region Registering The Client Function Thats Gets Fired When The Grid Loads
     //
     Literal litOnGridLoad = new Literal();
                    litOnGridLoad.Text = "<SCRIPT>" + this.strDataGridClientIdForJavaScript + SELECTONSINGLECLICK + "(" + strCurrentRow + ", '" + this.ItemStyle.CssClass + "', '" + this.SelectedItemStyle.CssClass + "', " + this.ClientID + ", 'stylesheet', document.forms[0]." + this.strHiddenSelectedRowNumber + ", document.forms[0]." + this.strHiddenOldStyleControl + ")</SCRIPT>";
     if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
     {
      litOnGridLoad.Text = litOnGridLoad.Text + "<SCRIPT>" + this.strClientSideFunctionForCheckBoxStateHeaderCheck + "</SCRIPT>"; 
     }

                    //litOnGridLoad.Text = litOnGridLoad.Text.Replace(ASPNETTWOFORMAT, ""); 
     this.Controls.Add(litOnGridLoad);
    #endregion
    #region Adding OnClick Events To Callers Button For Explicit Edit & Delete Event Calls
     //    
     if(!object.Equals(this.strEditClientButton, null))
     {
      //
      control = this.Page.FindControl(this.strEditClientButton);
      //
      if(control is HtmlButton)
      {
       ((HtmlButton)control).Attributes.Add("onclick", "eval(document.forms[0]."+ this.strHiddenEditEvent +".value)"); 
      }
      else if(control is Button)
      {
       ((Button)control).Attributes.Add("onclick", "eval(document.forms[0]."+ this.strHiddenEditEvent +".value);return false;");
      }    
     }
     //
     if(!object.Equals(this.strDeleteClientButton, null))
     {
      //
      control = this.Page.FindControl(this.strDeleteClientButton);
      //
      if(control is HtmlButton)
      {
       ((HtmlButton)control).Attributes.Add("onclick", "eval(document.forms[0]."+ this.strHiddenDeleteEvent +".value)"); 
      }
      else if(control is Button)
      {
       ((Button)control).Attributes.Add("onclick", "eval(document.forms[0]."+ this.strHiddenDeleteEvent +".value);return false;");
      }    
     }
    #endregion
    //
    //System.Web.HttpContext.Current.Response.Write("Hello");
   }
   catch(Exception exception)
   {
    this.RaiseException(exception);
   }
  }
  /// <summary>
  /// This Events Performs The Paging Operation & Call The AlladinDatabinding & AlladinException Event
  /// </summary>
  /// <param name="source"></param>
  /// <param name="e"></param>
  protected void AlladinDataGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
  {
   //try
   //{
    //
    this.CheckBoxStateDataCollection();
    //
    this.CurrentPageIndex = e.NewPageIndex;
    //
    this.RaiseDataGridBinding();
   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }
  /// <summary>
  /// This Event Performs The Edit Operation And Trigerrs The AlladinDataBinding, AlladinDataGridPageRedirect & AlladinException Event
  /// </summary>
  /// <param name="source"></param>
  /// <param name="e"></param>
  private void AlladinDataGrid_EditCommand(object source, DataGridCommandEventArgs e)
  {
   try
   {
    if(edittype.PageRedirect == this.edittypeEditType)
    {
     if(this.strCommandName.Length == INT_ZERO)
     {
      this.RaisePageRedirectEvent(e.Item, e.CommandName);
     }
     else
     {
      this.RaisePageRedirectEvent(e.Item, this.strCommandName);
     }
    }
    else
    {
     //
     this.EditItemIndex = e.Item.ItemIndex;

     this.blnEditOnDoubleClick = false;
     //
     this.RaiseDataGridBinding();
     //
     //this.ReBindDataGrid();
    }
   }
   catch(Exception exception)
   {
    this.RaiseException(exception);
   }
  }
  /// <summary>
  /// This Event Triggers The AlladinDeleteRow And AlladinException Event
  /// </summary>
  /// <param name="source"></param>
  /// <param name="e"></param>
  private void AlladinDataGrid_DeleteCommand(object source, DataGridCommandEventArgs e)
  {
   //try
   //{
    //
    if(object.Equals(this.AlladinDataGridDeleteRow, null))
    {
     //
     this.RaiseException(new ArgumentNullException("AlladinDataGridDeleteRow " + EVENTNULL));
    }
    else
    {
     //
     this.UpdateDataRowFromDataGridItem(this.dsGridData.Tables[this.strDataMemberName], e.Item); 
     //
     this.AlladinDataGridDeleteRow(this, this.dsGridData);
     //
     this.RaiseDataGridBinding();
    }        
   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }   
  /// <summary>
  /// This Event Triggers The AlladinUpdateRow And AlladinException Event
  /// </summary>
  /// <param name="source"></param>
  /// <param name="e"></param>
  private void AlladinDataGrid_UpdateCommand(object source, DataGridCommandEventArgs e)
  {
   //try
   //{
    //
    if(object.Equals(this.AlladinDataGridUpdateRow, null))
    {
     //
     this.RaiseException(new ArgumentNullException("AlladinDataGridUpdateRow " + EVENTNULL));   
    }
    else
    {
     //
     this.UpdateDataRowFromDataGridItem(this.dsGridData.Tables[this.strDataMemberName], e.Item);
     //
     this.AlladinDataGridUpdateRow(this, this.dsGridData);
    }
    //
    this.EditItemIndex = INT_NEGATIVE_ONE;
    //
    this.RaiseDataGridBinding();
   //}
   //catch(Exception exception)
   //{
    //
   // this.RaiseException(exception);
   //}
  }
  /// <summary>
  /// This Event Triggers The AlladinDatabinding And AlladinException Event.
  /// </summary>
  /// <param name="source"></param>
  /// <param name="e"></param>
  private void AlladinDataGrid_CancelCommand(object source, DataGridCommandEventArgs e)
  {
   //try
   //{
    //
    this.EditItemIndex = INT_NEGATIVE_ONE;
    //
    this.RaiseDataGridBinding();
    //
    //this.ReBindDataGrid();
   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }
  /// <summary>
  /// This Event Performs The Default Formatting Of Item Cells & Cells Controls
  /// And Also Triggers The AlladinException Event.
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void AlladinDataGrid_ItemCreated(object sender, DataGridItemEventArgs e)
  {
   //try
   //{
    //
    DataTable datatable = this.dsGridData.Tables[this.strDataMemberName];
    //
    if(ListItemType.Item == e.Item.ItemType)
    {
     #region Item Template
      //
      this.RegisterItemAttributesAndItemGraphicCaption(e, this.ItemStyle.CssClass);
      //
      this.DeleteLinkButtonOnClickAttribute(e);
      //
      this.FormatCellAlignment(e, datatable);
      //
      if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
      {
       foreach(Control control in e.Item.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal + this.intStartCellFrom].Controls)
       {
        if(control is CheckBox)
        {
         ((CheckBox)control).Attributes.Add(ONCLICK, this.strClientSideFunctionForCheckBoxStateHeaderCheck);  
         break;
        }
       }
      }
     #endregion
    }
    else if(ListItemType.AlternatingItem == e.Item.ItemType)
    {
     #region Alernating Item Template
      //
      this.RegisterItemAttributesAndItemGraphicCaption(e, this.AlternatingItemStyle.CssClass);
      //
      this.DeleteLinkButtonOnClickAttribute(e);
      //
      this.FormatCellAlignment(e, datatable);
      //
      if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
      {
       foreach(Control control in e.Item.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal + this.intStartCellFrom].Controls)
       {
        if(control is CheckBox)
        {
         ((CheckBox)control).Attributes.Add(ONCLICK, this.strClientSideFunctionForCheckBoxStateHeaderCheck);  
         break;
        }
       }
      }
     #endregion
    }
    else if(ListItemType.EditItem == e.Item.ItemType)
    {
     #region Edit Item Template
      //
      this.RegisterItemAttributesAndItemGraphicCaption(e, this.SelectedItemStyle.CssClass);
      //
      this.FormatCellAlignment(e, datatable);
      //     
      if(this.EditItemIndex == e.Item.ItemIndex)
      {
       //
       this.CancelLinkButtonOnClickattribute(e);
       //
       this.DeleteLinkButtonOnClickAttribute(e);     
      }
     #endregion
    }
    else if(ListItemType.Header == e.Item.ItemType) 
    {
     #region Header Item Template
      if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
      {
       if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(this.strCheckBoxStateColumnName)) 
       {
        //
        int intOrdinal = this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal;
        //
        if(this.blnEditColumnVisibility)
        {
         intOrdinal++;
        }
        //
        if(this.blnDeleteColumnVisibility)
        {
         intOrdinal++;
        }
        //
        int intRow;
        //
        if(this.AllowPaging)
        {
         intRow = INT_TWO;
        }
        else
        {
         intRow = INT_ONE; 
        }
        //       
        ((CheckBox)e.Item.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal + this.intStartCellFrom].Controls[INT_ZERO]).Attributes.Add(ONCLICK, this.strClientSideFunctionForCheckBoxState.Replace(CHECKBOXSTATEROWTYPE, "'"+ GridRowType.AllRows.ToString()+"'").Replace(CHECKBOXSTATETABLENAME, "document.all."+this.ClientID).Replace(CHECKBOXSTATEROW, intRow.ToString()).Replace(CHECKBOXSTATECELL, intOrdinal.ToString()));
       }
      }
      //
      if(this.decimalTotalNumberOfPages == INT_ZERO)
      {
       e.Item.Cells.Clear();  
      }
      else
      {
       if(this.captiontypeCaptionControlEditDeleteLink == captiontype.Graphics)
       {
        #region Adding The Edit & Delete Images
         //
         System.Web.UI.WebControls.Image editimage = new System.Web.UI.WebControls.Image();
         editimage.ImageUrl = this.strEditLinkImageLocation;
         //
         e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Add(editimage);
        
         //
         System.Web.UI.WebControls.Image deleteimage = new System.Web.UI.WebControls.Image();
         deleteimage.ImageUrl = this.strDeleteLinkImageLocation;
         //
         e.Item.Cells[this.intDeleteLinkColumnOrdinal].Controls.Add(deleteimage);      
        #endregion
       }     
      }
     #endregion
    }
    else if(ListItemType.Pager == e.Item.ItemType)
    {
                    #region Pager Item Template
                    if (this.AllowPaging)
                    {
                        //
                        Label lblCurrentPageLabel = null;
                        //
                        foreach (Control control in e.Item.Cells[INT_ZERO].Controls)
                        {
                            //
                            if (control is Label)
                            {
                                lblCurrentPageLabel = (Label)control;
                                break;
                            }
                        }
                        if (this.decimalTotalNumberOfPages == INT_ZERO)
                        {
                            if (this.intPagerCounter == INT_ZERO)
                            {
                                this.BorderWidth = INT_ZERO;
                                //
                                if (!object.Equals(lblCurrentPageLabel, null))
                                {
                                    lblCurrentPageLabel.Text = this.strNoRecordMessage;
                                }
                                //
                                e.Item.Cells[INT_ZERO].VerticalAlign = VerticalAlign.Top;
                                //
                                e.Item.Cells[INT_ZERO].HorizontalAlign = HorizontalAlign.Center;
                                //
                                this.blnSelectOnSingleClick = false;
                                //
                                this.intPagerCounter++;
                            }
                            else
                            {
                                e.Item.Cells.Clear();
                            }
                        }
                        else
                        {
                            //
                            this.BorderWidth = INT_ONE;
                            //
                            Table table = new Table();
                            //
                            table.CssClass = this.PagerStyle.CssClass;
                            //
                            TableRow tablerow = new TableRow();
                            //
                            table.Rows.Add(tablerow);
                            //
                            Label lblMessage = new Label();
                            //
                            lblMessage.Text = "Page " + lblCurrentPageLabel.Text + " Of " + this.decimalTotalNumberOfPages.ToString();
                            //
                            TableCell tablecell = new TableCell();
                            //
                            tablecell.Controls.Add(lblMessage);
                            //
                            table.Rows[INT_ZERO].Cells.Add(tablecell);
                            //
                            table.Rows[INT_ZERO].Cells.Add(e.Item.Cells[INT_ZERO]);
                            //
                            e.Item.Cells.Clear();
                            //
                            TableCell etablecell = new TableCell();
                            //
                            etablecell.Controls.Add(table);
                            //
                            etablecell.ColumnSpan = this.dsGridData.Tables[this.strDataMemberName].Columns.Count + this.intStartCellFrom;
                            //
                            e.Item.Cells.Add(etablecell);
                        }
                    }
                    #endregion
    }
   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }

  /// <summary>
  /// This Event Triggers The PageRedirectEvent when an LinkButton Is Click From Within the Cells
  /// </summary>
  /// <param name="source"></param>
  /// <param name="e"></param>
  private void AlladinDataGrid_ItemCommand(object source, DataGridCommandEventArgs e)
  {
   //try
   //{
    if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(e.CommandName))
    {
     if(!object.Equals(this.dsGridData.Tables[this.strDataMemberName].Columns[e.CommandName].ExtendedProperties[alladindatagridcelltype.LinkButton], null))
     {
      //if(edittype.PageRedirect == this.edittypeEditType)
      //{
       this.RaisePageRedirectEvent(e.Item, e.CommandName);
      //}            
     }     
    }
   //}
   //catch(Exception exception)
   //{
   // this.RaiseException(exception);
   //}
  }   
  
  #endregion
  #region Helper/Private Method
  /// <summary>
  /// This Helper Function Creates The ItemTemplate Columns.
  /// </summary>
  /// <param name="datatable">DataTable Which Is Source of Creating The Template Columns</param>
  private void SetColumnTemplate()
  {
   //
   int intEmailUrlColumnOrdinal = INT_NEGATIVE_ONE;
   //
   this.Columns.Clear();
   //
   this.AutoGenerateColumns = false;
   #region Creating Edit Command Column
    //Adding The Edit Hyper Link
    EditCommandColumn editCommandColumn = new EditCommandColumn();
    editCommandColumn.ButtonType = ButtonColumnType.LinkButton;
    editCommandColumn.EditText   = this.strEditColumnEditText;
    editCommandColumn.UpdateText = this.strEditColumnUpdateText;
    editCommandColumn.CancelText = this.strEditColumnCancelText;
    editCommandColumn.HeaderText = this.strEditColumnHeaderText;
    editCommandColumn.Visible = this.blnEditColumnVisibility;
   #endregion
   #region Creating Delete Column
    //add the delete column
    ButtonColumn deleteColumn = new ButtonColumn();
    deleteColumn.HeaderText  = this.strDeleteColumnHeaderText;
    deleteColumn.CommandName = this.strDeleteColumnDeleteText;
    deleteColumn.Text = this.strDeleteColumnDeleteText;
    deleteColumn.Visible = this.blnDeleteColumnVisibility; 
   #endregion
   #region Adding The Edit & Delete Columns
    if(this.intEditLinkColumnOrdinal == this.intDeleteLinkColumnOrdinal)
    {
     throw new Exception(EDITDELETELINKEXCEPTIONMESSAGE);  
    }
    //   
    if(this.intEditLinkColumnOrdinal == INT_ZERO) 
    {
     //Adding The Edit Hyper Link To The Columns Collection
     this.Columns.Add(editCommandColumn);     
     //Adding The Edit Hyper Link To The Columns Collection
     this.Columns.Add(deleteColumn);
    }
    //
    if(this.intDeleteLinkColumnOrdinal == INT_ZERO) 
    {
     //Adding The Edit Hyper Link To The Columns Collection
     this.Columns.Add(deleteColumn);
     //Adding The Edit Hyper Link To The Columns Collection
     this.Columns.Add(editCommandColumn);     
    }
   #endregion   
   //
   DataColumn[] primarykeycolumn = null;
   //
   DataRelationCollection datarelationcollection = null;
   //
   datarelationcollection = this.dsGridData.Relations;
   //
   primarykeycolumn = this.dsGridData.Tables[this.strDataMemberName].PrimaryKey;
   //
   foreach(DataColumn datacolumn in this.dsGridData.Tables[this.strDataMemberName].Columns)
   {
    #region Validatinig If A DataRelationShip Is Added On A Column Except A Primary Key Column
     //
     DataSet childdataset = null;
     //
     foreach(DataColumn primarykey in primarykeycolumn)
     {
      //
      if(primarykey.ColumnName != datacolumn.ColumnName)
      {
       if(object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DropDownMultipleControlDelimeter], null))
       {
        //
        foreach(DataRelation datarelation in datarelationcollection)
        {
         //
         DataColumn[] datacolumnrelationcollection = datarelation.ParentColumns;
         //
         foreach(DataColumn datacolumnrelation in datacolumnrelationcollection )
         {
          //
          if(datacolumnrelation.ColumnName == datacolumn.ColumnName)
          {
           //
           childdataset = new DataSet();
           //
           childdataset.Tables.Add(datarelation.ChildTable.Copy());
           //
           if(object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DropDownListDefaultTextField], null))
           {
            datacolumn.ExtendedProperties.Add(alladindatagridcelltype.DropDownListDefaultTextField, this.strDropDownListDefaultTextField); 
           }
          }
         }
        }        
       }
       else
       {
        //
        string[] strDataRelation = datacolumn.ExtendedProperties[alladindatagridcelltype.DropDownMultipleControlRelationName].ToString().Split(datacolumn.ExtendedProperties[alladindatagridcelltype.DropDownMultipleControlDelimeter].ToString().ToCharArray());
        //
        //
        childdataset = new DataSet();
        //
        childdataset.Tables.Add(datarelationcollection[strDataRelation[INT_ZERO]].ChildTable.Copy());
        //
        childdataset.Tables.Add(datarelationcollection[strDataRelation[INT_ONE]].ChildTable.Copy());
        //
        if(object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DropDownListDefaultTextField], null))
        {
         datacolumn.ExtendedProperties.Add(alladindatagridcelltype.DropDownListDefaultTextField, this.strDropDownListDefaultTextField); 
        }       
       }
      }
     }       
    #endregion
    #region Overidding The Default Messages, Min Max Values Of Range & Required Field Validators
     //DefaultRequiredFieldMessage
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRequiredFieldMessage], null))
     {
      if(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRequiredFieldMessage] is string)
      {
       this.strRequiredFieldValidatorDefaultMessage = datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRequiredFieldMessage].ToString();
      }
     }
     //DefaultRequiredFieldMessage
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorMessage], null))
     {
      if(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorMessage] is string)
      {
       this.strRangeValidatorDefaultMessage = datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorMessage].ToString();
      }
     }
     //DefaultRequiredFieldMessage
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorDecimalMinValue], null))
     {
      if(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorDecimalMinValue] is string)
      {
       this.strRangeValidatorDefaultDecimalMinValue = datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorDecimalMinValue].ToString();
      }
     }
     //DefaultRequiredFieldMessage
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorDecimalMaxValue], null))
     {
      if(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorDecimalMaxValue] is string)
      {
       this.strRangeValidatorDefaultDecimalMaxValue = datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorDecimalMaxValue].ToString();
      }
     }    
     //DefaultRequiredFieldMessage
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorIntegerMinValue], null))
     {
      if(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorIntegerMinValue] is string)
      {
       this.strRangeValidatorDefaultIntegerMinValue = datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorIntegerMinValue].ToString();
      }
     }    
     //DefaultRequiredFieldMessage
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorIntegerMaxValue], null))
     {
      if(datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorIntegerMaxValue] is string)
      {
       this.strRangeValidatorDefaultIntegerMaxValue = datacolumn.ExtendedProperties[alladindatagridcelltype.DefaultRangeValidatorIntegerMaxValue].ToString();
      }
     }    
    #endregion
    #region Validating The ExntendedProperty For EmailUrlColumnName
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.EmailColumnName], null))
     {
      if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(datacolumn.ExtendedProperties[alladindatagridcelltype.EmailColumnName].ToString()))
      {
       intEmailUrlColumnOrdinal = this.dsGridData.Tables[this.strDataMemberName].Columns[datacolumn.ExtendedProperties[alladindatagridcelltype.EmailColumnName].ToString()].Ordinal;
      }
      else
      {
       this.RaiseException(new Exception(datacolumn.ExtendedProperties[alladindatagridcelltype.EmailColumnName].ToString() + " Column Does Not Exits In " + this.strDataMemberName + " DataTable")); 
      }
     }
    #endregion
    #region Creating & Adding Item Template Columns At Runtime From The DataTables Columns Collection
     //Creating The Item Columns At Runtime
     TemplateColumn templatecol = new TemplateColumn();
     //
     templatecol.HeaderTemplate = new DataGridTemplate(ListItemType.Header, datacolumn, this.AllowSorting, this.blnFullyEditable, this.strDateFormat, childdataset, this.strRequiredFieldValidatorDefaultMessage, this.strRangeValidatorDefaultMessage, this.strRangeValidatorDefaultDecimalMinValue, this.strRangeValidatorDefaultDecimalMaxValue, this.strRangeValidatorDefaultIntegerMinValue, this.strRangeValidatorDefaultIntegerMaxValue, intEmailUrlColumnOrdinal, this.strReadOnlyTextBoxCss, this.textboxtypeDateControl, this.textboxtypeElipseButtonControl, this.checkboxstateCheckBoxState, this.strCheckBoxStateColumnName); 
     //
     templatecol.ItemTemplate = new DataGridTemplate(ListItemType.Item, datacolumn, this.AllowSorting, this.blnFullyEditable, this.strDateFormat, childdataset, this.strRequiredFieldValidatorDefaultMessage, this.strRangeValidatorDefaultMessage, this.strRangeValidatorDefaultDecimalMinValue, this.strRangeValidatorDefaultDecimalMaxValue, this.strRangeValidatorDefaultIntegerMinValue, this.strRangeValidatorDefaultIntegerMaxValue, intEmailUrlColumnOrdinal, this.strReadOnlyTextBoxCss, this.textboxtypeDateControl, this.textboxtypeElipseButtonControl, this.checkboxstateCheckBoxState, this.strCheckBoxStateColumnName);  
     //
     templatecol.FooterTemplate = new DataGridTemplate(ListItemType.Footer, datacolumn, this.AllowSorting, this.blnFullyEditable, this.strDateFormat, childdataset, this.strRequiredFieldValidatorDefaultMessage, this.strRangeValidatorDefaultMessage, this.strRangeValidatorDefaultDecimalMinValue, this.strRangeValidatorDefaultDecimalMaxValue, this.strRangeValidatorDefaultIntegerMinValue, this.strRangeValidatorDefaultIntegerMaxValue, intEmailUrlColumnOrdinal, this.strReadOnlyTextBoxCss, this.textboxtypeDateControl, this.textboxtypeElipseButtonControl, this.checkboxstateCheckBoxState, this.strCheckBoxStateColumnName);
     //
     templatecol.EditItemTemplate = new DataGridTemplate(ListItemType.EditItem, datacolumn, this.AllowSorting, this.blnFullyEditable, this.strDateFormat, childdataset, this.strRequiredFieldValidatorDefaultMessage, this.strRangeValidatorDefaultMessage, this.strRangeValidatorDefaultDecimalMinValue, this.strRangeValidatorDefaultDecimalMaxValue, this.strRangeValidatorDefaultIntegerMinValue, this.strRangeValidatorDefaultIntegerMaxValue, intEmailUrlColumnOrdinal, this.strReadOnlyTextBoxCss, this.textboxtypeDateControl, this.textboxtypeElipseButtonControl, this.checkboxstateCheckBoxState, this.strCheckBoxStateColumnName);
     //
     this.Columns.Add(templatecol);
    #endregion
    #region Validating The ExtendedProperty To Render Or Not To Render Column On Client Side
     //Validating The ExtendedProperty To Render Or Not To Render Column On Client Side    
     if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.Visibility], null))
     {
      if(datacolumn.ExtendedProperties[alladindatagridcelltype.Visibility] is string)
      {
       string strBool = datacolumn.ExtendedProperties[alladindatagridcelltype.Visibility].ToString();
       if(strBool == "true" || strBool == "false")
       {
        templatecol.Visible = bool.Parse(datacolumn.ExtendedProperties[alladindatagridcelltype.Visibility].ToString());
       }
      }
     }
    #endregion
   }
  }
  /// <summary>
  /// This Helper Function Performs A 64Bit Serialization Of The Object Which Implements ISerialize Interface.
  /// </summary>
  /// <param name="objSchemaXML">Object Which Is the Source Of The Data</param>
  /// <returns>Serialized String</returns>
  private string SerializeDataSchema(object objSchemaXML)
  {
   System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
   System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder);
   // Serialize the viewstate
   LosFormatter losFormatter = new LosFormatter();
   losFormatter.Serialize(stringWriter, objSchemaXML);
   stringWriter.Close();   
   return stringBuilder.ToString();
  }
  /// <summary>
  /// This Helper Function Deserializes the 64Bit String To DataSet Schema or Dataset
  /// </summary>
  /// <param name="strSchemaXML">Source Of The Data</param>
  /// <param name="strStatus">boolean Flag True to load Dataset & False to load Dataset Schema</param>
  /// <returns></returns>
  private DataSet DeserializeDataSchema(string strSchemaXML, bool strStatus)
  {
   // Deserialize the viewstate
   LosFormatter losFormatter = new LosFormatter();
   System.IO.StringReader sr = new System.IO.StringReader((string)losFormatter.Deserialize(strSchemaXML));    
   DataSet ds = new DataSet();    
   if(strStatus)
   {
    ds.ReadXml(sr);
   }
   else
   {
    ds.ReadXmlSchema(sr);
   }
   
   return ds;
  }
  /// <summary>
  /// Validates & Triggers The AlladinDataBinding Event.
  /// </summary>
  private void RaiseDataGridBinding()
  {
   //    
   if(object.Equals(AlladinsDataBinding, null))
   {
    throw new ArgumentNullException("AlladinsDataBinding " + EVENTNULL);
   }
   else
   {
    this.AlladinsDataBinding();
   }    
  }
  /// <summary>
  /// Validates & Triggers The AlladinException Event
  /// </summary>
  /// <param name="exception"></param>
  private void RaiseException(Exception exception)
  {
   if(object.Equals(AlladinDataGridException, null))
   {
    throw new ArgumentNullException("AlladinsDataGridException " + EVENTNULL); 
   }
   else
   {
    this.AlladinDataGridException(this, exception);   
   }
  }
  /// <summary>
  /// Iterates The DataGrid Items And Updates It In A DataSet Which is Derived From Datasource.
  /// </summary>
  private void UpdateDataSetFromDataGrid()
  {
   foreach(DataGridItem datagriditem in this.Items)
   {
    this.UpdateDataRowFromDataGridItem(this.dsGridData.Tables[this.strDataMemberName], datagriditem);
   }
  }
  /// <summary>
  /// Updates Specific DataGridItems To A DataSet Derived From The Datasource
  /// </summary>
  /// <param name="datagriditem">DataGridItem Type</param>
  private void UpdateDataRowFromDataGridItem(DataTable datatable, DataGridItem datagriditem)
  {
   //
   int intTableCellCounter = INT_ZERO;
     //Adding a New Row
   DataRow datarow = datatable.NewRow();   
   //
   foreach(TableCell tablecell in datagriditem.Cells)
   {
    //Validating if ctr is equal to greator than datacolumns;
    if(intTableCellCounter >= this.intStartCellFrom)
    {
     //
     bool blnMultipleDropDownControl = false;
     //
     foreach(Control control in tablecell.Controls)
     {
      if(control is Literal)
      {
       //
       if(blnMultipleDropDownControl) break;
       //
       if(this.dsGridData.Tables[this.strDataMemberName].Columns[this.intDataColumnCounter].DataType.ToString() == SYSTEMDATETIME)
       {
        datarow[this.intDataColumnCounter] = this.ConvertStringToDateTime(((Literal)control).Text); 
        break;
       }
       else
       {
        datarow[this.intDataColumnCounter] = this.SetDataSetValue(((Literal)control).Text);
        break;
       }
      }
      else if(control is TextBox)
      {
       //
       if(blnMultipleDropDownControl) break;
       //
       if(this.dsGridData.Tables[this.strDataMemberName].Columns[this.intDataColumnCounter].DataType.ToString() == SYSTEMDATETIME)
       {
        datarow[this.intDataColumnCounter] = this.ConvertStringToDateTime( ((TextBox)control).Text); 
        break;
       }
       else
       {
        datarow[this.intDataColumnCounter] = this.SetDataSetValue(((TextBox)control).Text);
        break;
       }
      }
      else if(control is CheckBox)
      {
       if(blnMultipleDropDownControl) break;
       datarow[this.intDataColumnCounter] = ((CheckBox)control).Checked;
       break;
      }
      else if(control is DropDownList)
      {
       if(!object.Equals(datatable.Columns[this.intDataColumnCounter].ExtendedProperties[alladindatagridcelltype.DropDownMultipleControlDelimeter], null))
       {
        blnMultipleDropDownControl = true;
       }
       else
       {
        blnMultipleDropDownControl = false;
       }
       
       if(datarow[this.intDataColumnCounter].ToString().Length == INT_ZERO)
       {
        datarow[this.intDataColumnCounter] = this.SetDataSetValue(((DropDownList)control).Items[((DropDownList)control).SelectedIndex].Value);
       }
       else
       {
        //
        string strDelimeter = datatable.Columns[this.intDataColumnCounter].ExtendedProperties[alladindatagridcelltype.DropDownMultipleControlDelimeter].ToString();
        //
        if(strDelimeter.Length == INT_ZERO) strDelimeter = " ";
        //
        datarow[this.intDataColumnCounter] = datarow[this.intDataColumnCounter] + strDelimeter + this.SetDataSetValue(((DropDownList)control).Items[((DropDownList)control).SelectedIndex].Value);        
       }
       if(!blnMultipleDropDownControl) break;       
      }
      else if(control is LinkButton)
      {
       if(blnMultipleDropDownControl) break;
       datarow[this.intDataColumnCounter] = this.SetDataSetValue(((LinkButton)control).Text);
       break;       
      }
      else if(control is HyperLink)
      {
       if(blnMultipleDropDownControl) break;
       datarow[this.intDataColumnCounter] = this.SetDataSetValue(((HyperLink)control).Text);
       break;       
      }
     }
     //
     this.intDataColumnCounter++;     
    }
    //
    intTableCellCounter++;
   }
   //
   datatable.Rows.Add(datarow);
   //Re-inisializing the member variable
   this.intDataColumnCounter = INT_ZERO;
  }
  /// <summary>
  /// Returns A DBNull Value Or The InputData If It Is Not Blank
  /// </summary>
  /// <param name="strData">String Type Which is The source Of Data</param>
  /// <returns>Object type eithere DBNull or String</returns>
  private object SetDataSetValue(string strData)
  {
   if(INT_ZERO < strData.Length)
   {
    return strData;
   }
   else
   {
    return DBNull.Value; 
   }
  }
  /// <summary>
  /// registers ClientSide function scripts to the page class
  /// </summary>
  private void RegistetrClientScripts()
  {
   #region ClientSide Script For SelectOnSingleClick
    //Creating The ClientSide Script For SelectOnSingleClick With StringBuilder Class
    StringBuilder sbSelectOnSingleClick = new StringBuilder();
    //
    sbSelectOnSingleClick.Append("<SCRIPT>");
    sbSelectOnSingleClick.Append("function " + this.strDataGridClientIdForJavaScript + SELECTONSINGLECLICKFUNCTIONNAME);  
    sbSelectOnSingleClick.Append("{");
     //Validating if Variable Is True To Register This Code In Client Function
     if(this.blnSelectOnSingleClick)
     {
      sbSelectOnSingleClick.Append("var previousrow = "+ INT_NEGATIVE_ONE +";");
      sbSelectOnSingleClick.Append("if(tablename.rows[row] == null) return;");
      sbSelectOnSingleClick.Append("var currentrow  = tablename.rows[row];");
      sbSelectOnSingleClick.Append("if(hidcontrol.value > "+ INT_NEGATIVE_ONE +")");
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("if(!isNaN(hidcontrol.value))"); 
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("previousrow = hidcontrol.value;");
      sbSelectOnSingleClick.Append("}");
      sbSelectOnSingleClick.Append("}");
      sbSelectOnSingleClick.Append("if(type == 'stylesheet')");
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("if(previousrow > "+ INT_NEGATIVE_ONE +")");
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("tablename.rows[previousrow].className = hidstylecontrol.value;");
      sbSelectOnSingleClick.Append("if(event != null)");
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("hidstylecontrol.value = event.srcElement.parentElement.className;");
      sbSelectOnSingleClick.Append("}");
      sbSelectOnSingleClick.Append("}");
      sbSelectOnSingleClick.Append("currentrow.className = selectedclassname;"); 
      sbSelectOnSingleClick.Append("}");
      sbSelectOnSingleClick.Append("else");
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("if(previousrow > "+ INT_NEGATIVE_ONE +")");
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("tablename.rows[previousrow].style.backgroundColor = hidstylecontrol.value;");
      sbSelectOnSingleClick.Append("if(event != null)");
      sbSelectOnSingleClick.Append("{");
      sbSelectOnSingleClick.Append("hidstylecontrol.value = event.srcElement.style.backgroundColor;");
      sbSelectOnSingleClick.Append("}");
      sbSelectOnSingleClick.Append("}");
      sbSelectOnSingleClick.Append("currentrow.style.backgroundColor = selectedclassname;"); 
      sbSelectOnSingleClick.Append("}");
     }
    sbSelectOnSingleClick.Append("hidcontrol.value = row;");      
    sbSelectOnSingleClick.Append("}");
    sbSelectOnSingleClick.Append("</SCRIPT>");
    this.Page.RegisterClientScriptBlock(this.strDataGridClientIdForJavaScript + SELECTONSINGLECLICKSTRINBUILDER, sbSelectOnSingleClick.ToString());
   #endregion
   #region ClientSide Script For ExplicitDeleteEvent
    //Creating The ClientSide Script For SelectOnSingleClick With StringBuilder Class
    StringBuilder sbDeleteEventClick = new StringBuilder();
    //
    sbDeleteEventClick.Append("<SCRIPT>");
    sbDeleteEventClick.Append("function " + this.strDeleteClientFunctionName);
    sbDeleteEventClick.Append("{");    
    if(this.deletetypeDeleteType == deletetype.DeleteWithConfirmation)
    {
     sbDeleteEventClick.Append("if(confirm('"+ this.strDeleteConfirmationMessage +"'))");
    }
    sbDeleteEventClick.Append("alert(document.forms[0]."+ this.strHiddenDeleteEvent +".value);");
    sbDeleteEventClick.Append("eval(document.forms[0]."+ this.strHiddenDeleteEvent +".value);");
    sbDeleteEventClick.Append("}");
    sbDeleteEventClick.Append("</SCRIPT>");
    this.Page.RegisterClientScriptBlock(this.strDataGridClientIdForJavaScript + DELETEEVENT, sbDeleteEventClick.ToString());
   #endregion
   #region ClientSide Script For ExplicitEditEvent
    //Creating The ClientSide Script For SelectOnSingleClick With StringBuilder Class
    StringBuilder sbEditEventClick = new StringBuilder();
    //
    sbEditEventClick.Append("<SCRIPT>");
    sbEditEventClick.Append("function " + this.strEditClientFunctionName);
    sbEditEventClick.Append("{");    
    sbEditEventClick.Append("if(event.srcElement.type == 'button')");
    sbEditEventClick.Append("{");
    sbEditEventClick.Append("document.forms[0]."+ this.strHiddenCommandName +".value = event.srcElement.value;");
    sbEditEventClick.Append("}");
    sbEditEventClick.Append("eval(document.forms[0]."+ this.strHiddenEditEvent +".value);");
    sbEditEventClick.Append("}");
    sbEditEventClick.Append("</SCRIPT>");
    this.Page.RegisterClientScriptBlock(this.strDataGridClientIdForJavaScript + EDITEVENT, sbEditEventClick.ToString());
   #endregion
   #region ClientSide Script For ExplicitSelectedRowNo
    //Creating The ClientSide Script For SelectOnSingleClick With StringBuilder Class
    StringBuilder sbSelectedRow = new StringBuilder();
    //
    sbSelectedRow.Append("<SCRIPT>");
    sbSelectedRow.Append("function " + this.strSelectedRowNoClientFunctionName);
    sbSelectedRow.Append("{");    
    sbSelectedRow.Append("return document.forms[0]."+ this.strHiddenSelectedRowNumber +".value;");
    sbSelectedRow.Append("}");
    sbSelectedRow.Append("</SCRIPT>");
    this.Page.RegisterClientScriptBlock(this.strDataGridClientIdForJavaScript + STRINGBUILDERSELECTEDROWNO, sbSelectedRow.ToString());
   #endregion
   #region ClientSide Script For ExplicitSelectedRowId
    //Creating The ClientSide Script For SelectOnSingleClick With StringBuilder Class
    StringBuilder sbSelectedRowId = new StringBuilder();
    //
    sbSelectedRowId.Append("<SCRIPT>");
    sbSelectedRowId.Append("function " + this.strSelectedRowIdClientFunctionName);
    sbSelectedRowId.Append("{");    
    sbSelectedRowId.Append("return document.all." + this.ClientID + ".rows[document.forms[0]."+ this.strHiddenSelectedRowNumber +".value].id;");
    sbSelectedRowId.Append("}");
    sbSelectedRowId.Append("</SCRIPT>");
    this.Page.RegisterClientScriptBlock(this.strDataGridClientIdForJavaScript + STRINGBUILDERSELECTEDROWID, sbSelectedRowId.ToString());
   #endregion
   #region ClientSide Script For ExplicitItemRowData
      
   #endregion
   #region ClientSide Script For ExplicitDataRow
    if(this.blnPersistDataRowInGridItem)
    {
     StringBuilder sbDataRow = new StringBuilder();
     //
     sbDataRow.Append("<SCRIPT>");
     sbDataRow.Append("function " + this.strClientSideFunctionForDataRow);
     sbDataRow.Append("{");    
     sbDataRow.Append("var rowdata = document.all."+ this.ClientID +".getElementsByTagName(\""+TR+"\");");
     sbDataRow.Append("return rowdata[document.forms[0]."+ this.strHiddenSelectedRowNumber +".value]."+ DATAROWITEMATTRIBUTE + ";");
     sbDataRow.Append("}");
     sbDataRow.Append("</SCRIPT>");    
     //
     this.Page.RegisterClientScriptBlock(this.strClientSideFunctionForDataRow, sbDataRow.ToString());     
    }
   #endregion
   #region ClientSide Script For CheckBoxStateAcrossPages
    StringBuilder sbCheckboxState = new StringBuilder();
    //
    sbCheckboxState.Append("<SCRIPT>");
    sbCheckboxState.Append("function " + this.strClientSideFunctionForCheckBoxState);
    sbCheckboxState.Append("{");    
    sbCheckboxState.Append("if(" + CHECKBOXSTATEROWTYPE + " == '" + GridRowType.AllRows.ToString() + "')");
    sbCheckboxState.Append("{");
     sbCheckboxState.Append("var headerrow = " + CHECKBOXSTATEROW + " - " + INT_ONE + ";"); 
      sbCheckboxState.Append("for(; "+ CHECKBOXSTATEROW +" < "+ CHECKBOXSTATETABLENAME +".rows.length; "+ CHECKBOXSTATEROW +"++)");
       sbCheckboxState.Append("{");
          sbCheckboxState.Append("if(tablename.rows[row].cells.length >= "+ CHECKBOXSTATECELL +")");
           sbCheckboxState.Append("{");
            sbCheckboxState.Append("for(child = "+ INT_ZERO + "; child < "+ CHECKBOXSTATETABLENAME +".rows["+ CHECKBOXSTATEROW +"].cells["+ CHECKBOXSTATECELL +"].children.length; child++)");
             sbCheckboxState.Append("{");
              sbCheckboxState.Append("if("+ CHECKBOXSTATETABLENAME +".rows["+ CHECKBOXSTATEROW +"].cells["+ CHECKBOXSTATECELL +"].children[child].type == 'checkbox')");
               sbCheckboxState.Append("{");
                sbCheckboxState.Append("if(!"+ CHECKBOXSTATETABLENAME +".rows["+ CHECKBOXSTATEROW +"].cells["+ CHECKBOXSTATECELL +"].children[child].disabled)");
                 sbCheckboxState.Append("{");
                  sbCheckboxState.Append("if("+ CHECKBOXSTATETABLENAME +".rows[headerrow].cells["+ CHECKBOXSTATECELL +"].children["+ INT_ZERO +"].checked)");
                   sbCheckboxState.Append("{");
                    sbCheckboxState.Append(CHECKBOXSTATETABLENAME +".rows["+ CHECKBOXSTATEROW +"].cells["+ CHECKBOXSTATECELL +"].children[child].checked = true;");
                   sbCheckboxState.Append("}");
                  sbCheckboxState.Append("else");
                   sbCheckboxState.Append("{");
                    sbCheckboxState.Append(CHECKBOXSTATETABLENAME +".rows["+ CHECKBOXSTATEROW +"].cells["+ CHECKBOXSTATECELL +"].children[child].checked = false;");
                   sbCheckboxState.Append("}");
                 sbCheckboxState.Append("}");
               sbCheckboxState.Append("}");
             sbCheckboxState.Append("}");
           sbCheckboxState.Append("}");
       sbCheckboxState.Append("}");
    sbCheckboxState.Append("}");
    //sbCheckboxState.Append("");
    //sbCheckboxState.Append("else");
    //sbCheckboxState.Append("{");
    //sbCheckboxState.Append("}");
    sbCheckboxState.Append("}");
    sbCheckboxState.Append("</SCRIPT>");
    //
    this.Page.RegisterClientScriptBlock(this.strClientSideFunctionForCheckBoxState, sbCheckboxState.ToString());
   #endregion
   #region ClientSide Script For Checked Records Count Across Pages
   StringBuilder sbCheckboxStateRecordCount = new StringBuilder();
   //
   sbCheckboxStateRecordCount.Append("<SCRIPT>");
   sbCheckboxStateRecordCount.Append("function " + this.strClientSideFunctionForCheckBoxStateRecordCount);
   sbCheckboxStateRecordCount.Append("{");
   sbCheckboxStateRecordCount.Append("var previouspagecount = "+INT_ZERO +";");
   sbCheckboxStateRecordCount.Append("var currentpagecount = "+INT_ZERO+";");
   sbCheckboxStateRecordCount.Append("var row = "+INT_NEGATIVE_ONE+";");
   sbCheckboxStateRecordCount.Append("var cell = "+INT_NEGATIVE_ONE+";");
   sbCheckboxStateRecordCount.Append("var tablename = document.all."+this.ClientID+";");
   //
   if(this.dsCheckBoxState.Tables.Count > INT_ZERO)
   {
    //
    if(this.dsCheckBoxState.Tables[this.strDataMemberName].Rows.Count > INT_ZERO)
    {
     int intCheckedRecordCount;
     //
     //this.dsCheckBoxState.Tables[this.strDataMemberName].DefaultView.RowFilter = PAGENUMBERDATACOLUMN +"="+ this.CurrentPageIndex; 
     //
     intCheckedRecordCount = this.dsCheckBoxState.Tables[this.strDataMemberName].Rows.Count;
     //
     foreach(DataGridItem datagriditem in this.Items)
     {
      foreach(Control control in datagriditem.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal + this.intStartCellFrom].Controls)
      {
       if(control is CheckBox) 
       {
        if(((CheckBox)control).Checked)
        {
         intCheckedRecordCount--;
        }
        break;
       }
      }
     }
     //
     sbCheckboxStateRecordCount.Append("previouspagecount = "+ intCheckedRecordCount +";");
    }
   }
   //   
   if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
   {
    //
    if(this.AllowPaging)
    {
     sbCheckboxStateRecordCount.Append("row = " + INT_TWO+";");
    }
    else
    {
     sbCheckboxStateRecordCount.Append("row = " + INT_ONE+";");
    }
    //
    if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(this.strCheckBoxStateColumnName))
    {
     //
     sbCheckboxStateRecordCount.Append("cell = " + this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal+";");
     //
     if(this.EditColumnVisibility)
     {
      sbCheckboxStateRecordCount.Append("cell = cell + " + INT_ONE+";");
     }
     //
     if(this.DeleteColumnVisibility)
     {
      sbCheckboxStateRecordCount.Append("cell = cell + " + INT_ONE+";");
     }
    }
    //
    sbCheckboxStateRecordCount.Append("if(row > " + INT_NEGATIVE_ONE + ")");
     sbCheckboxStateRecordCount.Append("{");
      sbCheckboxStateRecordCount.Append("for(; row < tablename.rows.length; row++)");
       sbCheckboxStateRecordCount.Append("{");
        sbCheckboxStateRecordCount.Append("if(cell > " + INT_NEGATIVE_ONE + ")");
         sbCheckboxStateRecordCount.Append("{");
          sbCheckboxStateRecordCount.Append("if(tablename.rows[row].cells.length >= cell)");
           sbCheckboxStateRecordCount.Append("{");
            sbCheckboxStateRecordCount.Append("for(var child = "+ INT_ZERO +"; child < tablename.rows[row].cells[cell].children.length; child++)");
             sbCheckboxStateRecordCount.Append("{");    
              sbCheckboxStateRecordCount.Append("if(tablename.rows[row].cells[cell].children[child].type == 'checkbox')");
               sbCheckboxStateRecordCount.Append("{");
                sbCheckboxStateRecordCount.Append("if(!tablename.rows[row].cells[cell].children[child].disabled)");
                 sbCheckboxStateRecordCount.Append("{");
                  sbCheckboxStateRecordCount.Append("if(tablename.rows[row].cells[cell].children[child].checked)");
                   sbCheckboxStateRecordCount.Append("{");
                    //sbCheckboxStateRecordCount.Append("alert(tablename.rows[row].cells[cell].children[child].checked);"); 
                    sbCheckboxStateRecordCount.Append("currentpagecount++;");
                   sbCheckboxStateRecordCount.Append("}");
                 sbCheckboxStateRecordCount.Append("}");
               sbCheckboxStateRecordCount.Append("}");    
             sbCheckboxStateRecordCount.Append("}");
           sbCheckboxStateRecordCount.Append("}"); 
         sbCheckboxStateRecordCount.Append("}");
       sbCheckboxStateRecordCount.Append("}");
     sbCheckboxStateRecordCount.Append("}");
   }
   sbCheckboxStateRecordCount.Append("return previouspagecount + currentpagecount;");
   sbCheckboxStateRecordCount.Append("}");
   sbCheckboxStateRecordCount.Append("</SCRIPT>");
   //
   this.Page.RegisterClientScriptBlock(this.strClientSideFunctionForCheckBoxStateRecordCount, sbCheckboxStateRecordCount.ToString());
   #endregion
   #region ClientSide Script For Checked Records Across Pages Header CheckBox
   StringBuilder sbCheckboxStateHeaderCheck = new StringBuilder();
   //
   sbCheckboxStateHeaderCheck.Append("<SCRIPT>");
   sbCheckboxStateHeaderCheck.Append("function " + this.strClientSideFunctionForCheckBoxStateHeaderCheck);
   sbCheckboxStateHeaderCheck.Append("{");
   sbCheckboxStateHeaderCheck.Append("var totalrows = " + INT_ZERO + ";");
   sbCheckboxStateHeaderCheck.Append("var cell = " + INT_NEGATIVE_ONE + ";");
   sbCheckboxStateHeaderCheck.Append("var headerrow = " + INT_NEGATIVE_ONE + ";");
   sbCheckboxStateHeaderCheck.Append("var row = "+INT_NEGATIVE_ONE+";");
   sbCheckboxStateHeaderCheck.Append("var currentcheckedcount = " + INT_ZERO + ";");
   sbCheckboxStateHeaderCheck.Append("var tablename = document.all."+this.ClientID+";");
   //   
   if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
   {
    //
    if(this.AllowPaging)
    {
     sbCheckboxStateHeaderCheck.Append("headerrow = " + INT_ONE+";");
     sbCheckboxStateHeaderCheck.Append("row = " + INT_TWO+";");
    }
    else
    {
     sbCheckboxStateHeaderCheck.Append("headerrow = " + INT_ZERO+";");
     sbCheckboxStateHeaderCheck.Append("row = " + INT_ONE+";");
    }
    //
    sbCheckboxStateHeaderCheck.Append("totalrows = " + (this.Items.Count - this.intReadOnlyItemCount) + ";");
    //
    if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(this.strCheckBoxStateColumnName))
    {
     //
     sbCheckboxStateHeaderCheck.Append("cell = " + this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal+";");
     //
     if(this.EditColumnVisibility)
     {
      sbCheckboxStateHeaderCheck.Append("cell = cell + " + INT_ONE+";");
     }
     //
     if(this.DeleteColumnVisibility)
     {
      sbCheckboxStateHeaderCheck.Append("cell = cell + " + INT_ONE+";");
     }
    }   
    //
    sbCheckboxStateHeaderCheck.Append("if(row > " + INT_NEGATIVE_ONE + ")");
     sbCheckboxStateHeaderCheck.Append("{");
      //sbCheckboxStateHeaderCheck.Append("alert();"); 
      sbCheckboxStateHeaderCheck.Append("for(; row < tablename.rows.length; row++)");
       sbCheckboxStateHeaderCheck.Append("{");
        sbCheckboxStateHeaderCheck.Append("if(cell > " + INT_NEGATIVE_ONE + ")");
         sbCheckboxStateHeaderCheck.Append("{");
          sbCheckboxStateHeaderCheck.Append("if(tablename.rows[row].cells.length >= cell)");
           sbCheckboxStateHeaderCheck.Append("{");
            sbCheckboxStateHeaderCheck.Append("for(var child = "+ INT_ZERO +"; child < tablename.rows[row].cells[cell].children.length; child++)");
             sbCheckboxStateHeaderCheck.Append("{");    
              sbCheckboxStateHeaderCheck.Append("if(tablename.rows[row].cells[cell].children[child].type == 'checkbox')");
               sbCheckboxStateHeaderCheck.Append("{");
                sbCheckboxStateHeaderCheck.Append("if(!tablename.rows[row].cells[cell].children[child].disabled)");
                 sbCheckboxStateHeaderCheck.Append("{");
                  sbCheckboxStateHeaderCheck.Append("if(tablename.rows[row].cells[cell].children[child].checked)");
                   sbCheckboxStateHeaderCheck.Append("{");
                    sbCheckboxStateHeaderCheck.Append("currentcheckedcount++;");
                   sbCheckboxStateHeaderCheck.Append("}");
                 sbCheckboxStateHeaderCheck.Append("}");
               sbCheckboxStateHeaderCheck.Append("}");    
             sbCheckboxStateHeaderCheck.Append("}");
           sbCheckboxStateHeaderCheck.Append("}");
         sbCheckboxStateHeaderCheck.Append("}");
       sbCheckboxStateHeaderCheck.Append("}");
     sbCheckboxStateHeaderCheck.Append("}");
    //sbCheckboxStateHeaderCheck.Append("alert(totalrows);");
    //sbCheckboxStateHeaderCheck.Append("alert(currentcheckedcount);");
    sbCheckboxStateHeaderCheck.Append("if(totalrows == currentcheckedcount)");
     sbCheckboxStateHeaderCheck.Append("{");
     //sbCheckboxStateHeaderCheck.Append("alert('Hello ' + headerrow);");
      sbCheckboxStateHeaderCheck.Append("for(var child = "+ INT_ZERO +"; child < tablename.rows[headerrow].cells[cell].children.length; child++)");
       sbCheckboxStateHeaderCheck.Append("{");    
        sbCheckboxStateHeaderCheck.Append("if(tablename.rows[headerrow].cells[cell].children[child].type == 'checkbox')");
         sbCheckboxStateHeaderCheck.Append("{");
          sbCheckboxStateHeaderCheck.Append("if(!tablename.rows[headerrow].cells[cell].children[child].disabled)");
           sbCheckboxStateHeaderCheck.Append("{");
            sbCheckboxStateHeaderCheck.Append("tablename.rows[headerrow].cells[cell].children[child].checked = true;");
           sbCheckboxStateHeaderCheck.Append("}");
         sbCheckboxStateHeaderCheck.Append("}");    
       sbCheckboxStateHeaderCheck.Append("}");
     sbCheckboxStateHeaderCheck.Append("}");
    sbCheckboxStateHeaderCheck.Append("else");
     sbCheckboxStateHeaderCheck.Append("{");
      sbCheckboxStateHeaderCheck.Append("for(var child = "+ INT_ZERO +"; child < tablename.rows[headerrow].cells[cell].children.length; child++)");
       sbCheckboxStateHeaderCheck.Append("{");    
        sbCheckboxStateHeaderCheck.Append("if(tablename.rows[headerrow].cells[cell].children[child].type == 'checkbox')");
         sbCheckboxStateHeaderCheck.Append("{");
          sbCheckboxStateHeaderCheck.Append("if(!tablename.rows[headerrow].cells[cell].children[child].disabled)");
           sbCheckboxStateHeaderCheck.Append("{");
            sbCheckboxStateHeaderCheck.Append("tablename.rows[headerrow].cells[cell].children[child].checked = false;");
           sbCheckboxStateHeaderCheck.Append("}");
         sbCheckboxStateHeaderCheck.Append("}");    
       sbCheckboxStateHeaderCheck.Append("}");
     sbCheckboxStateHeaderCheck.Append("}"); 
   }
   sbCheckboxStateHeaderCheck.Append("}");
   sbCheckboxStateHeaderCheck.Append("</SCRIPT>");
   //
   this.Page.RegisterClientScriptBlock(this.strClientSideFunctionForCheckBoxStateHeaderCheck, sbCheckboxStateHeaderCheck.ToString());
   #endregion
   #region ClientSide Script For ElipseButton
    //StringBuilder sbElipseButton = new StringBuilder();
    //
    //sbElipseButton.Append("<SCRIPT>");
    //sbElipseButton.Append("function " + this.strElipseButtonClientSideFunction);
    //sbElipseButton.Append("{");    
    //sbElipseButton.Append("return "+ TEXTBOXCONTROL +";");
    //sbElipseButton.Append("}");
    //sbElipseButton.Append("</SCRIPT>");    
    //
    //this.Page.RegisterClientScriptBlock(this.strElipseButtonClientSideFunction, sbElipseButton.ToString());
   #endregion
  }
  /// <summary>
  /// Registers Onclick & OnDouble click clientside events
  /// </summary>
  /// <param name="e">DataGridItemEventArgs type which is the source of data</param>
  /// <param name="cssClass">String Type which is the source of data</param>
  private void RegisterItemAttributesAndItemGraphicCaption(DataGridItemEventArgs e, string strCSSClass)
  {
   //
   int intItemNumber = e.Item.ItemIndex + INT_ONE;
   //    
   int intItemNumberForDoubleClick = e.Item.ItemIndex + INT_TWO;
   //
   if(this.AllowPaging)
   {
    ++intItemNumber;
    ++intItemNumberForDoubleClick;
   }
   //
   if(captiontype.Graphics == this.captiontypeCaptionControlEditDeleteLink)
   {
    //
    if(this.EditItemIndex != e.Item.ItemIndex)
    {
     #region Adding Graphic Caption For The Row
      System.Web.UI.WebControls.Image editimage = new System.Web.UI.WebControls.Image();
      editimage.ImageUrl = this.strEditLinkImageLocation;
      e.Item.Cells[this.intEditLinkColumnOrdinal].Controls[INT_ZERO].Visible = false;   
      e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Add(editimage);
      editimage.Attributes.Add(ONCLICK, "document.forms[0]." + this.strHiddenSelectedRowNumber + ".value="+ intItemNumber.ToString() +";document.forms[0]."+ this.strHiddenEditEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count, true)+"';eval(document.forms[0]."+ this.strHiddenEditEvent +".value);");       
      //
      System.Web.UI.WebControls.Image deleteimage = new System.Web.UI.WebControls.Image();
      deleteimage.ImageUrl = this.strDeleteLinkImageLocation;
      e.Item.Cells[this.intDeleteLinkColumnOrdinal].Controls[INT_ZERO].Visible = false;   
      e.Item.Cells[this.intDeleteLinkColumnOrdinal].Controls.Add(deleteimage);
      deleteimage.Attributes.Add(ONCLICK, "if(confirm('"+ this.strDeleteConfirmationMessage +"')){document.forms[0]." + this.strHiddenSelectedRowNumber + ".value="+ intItemNumber.ToString() +";document.forms[0]."+ this.strHiddenDeleteEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count + INT_ONE, true)+"'; eval(document.forms[0]."+ this.strHiddenDeleteEvent +".value);}");
      //
      e.Item.Attributes.Add(ONCLICK, this.strDataGridClientIdForJavaScript + "SelectOnSingleClick(" + intItemNumber.ToString() + ", '"+ strCSSClass +"', '"+ this.SelectedItemStyle.CssClass +"', " + this.ClientID + ", 'stylesheet', document.forms[0]." + this.strHiddenSelectedRowNumber + ", document.forms[0]."+ this.strHiddenOldStyleControl +");document.forms[0]."+ this.strHiddenEditEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count, true)+"';document.forms[0]."+ this.strHiddenDeleteEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count + INT_ONE, true)+"';");
      //e.Item.Attributes.Add(ONCLICK, this.strDataGridClientIdForJavaScript + "SelectOnSingleClick(" + intItemNumber.ToString() + ", '"+ strCSSClass +"', '"+ this.SelectedItemStyle.CssClass +"', " + this.ClientID + ", 'stylesheet', document.forms[0]." + this.strHiddenSelectedRowNumber + ", document.forms[0]."+ this.strHiddenOldStyleControl +");document.forms[0]."+ this.strHiddenEditEvent +".value='"+ DOPOSTBACKCLIENTFUNCTION +"(\\'" + this.ClientID + DOLLAR + UNDERSCORE + CTL + intItemNumberForDoubleClick + DOLLAR + UNDERSCORE + CTL + this.intEditLinkColumnOrdinal + "\\', \\'\\')';document.forms[0]."+ this.strHiddenDeleteEvent +".value='" + DOPOSTBACKCLIENTFUNCTION + "(\\'" + this.ClientID + DOLLAR + UNDERSCORE + CTL + intItemNumberForDoubleClick + DOLLAR + UNDERSCORE + CTL + this.intDeleteLinkColumnOrdinal +"\\', \\'\\')';");
      //
      if(this.blnEditOnDoubleClick)
      {
       e.Item.Attributes.Add(ONDBLCLICK, "eval(document.forms[0]."+ this.strHiddenEditEvent +".value);");
       //e.Item.Attributes.Add(ONDBLCLICK, "__doPostBack('" + this.ClientID + "$_ctl" + intItemNumberForDoubleClick + "$_ctl0', '')");
      }    
     #endregion 
    }
    else
    {
     #region Adding Graphic Caption If Row Is In Edit Mode
      System.Web.UI.WebControls.Image applyimage = new System.Web.UI.WebControls.Image();
      applyimage.ImageUrl = this.strApplyLinkImageLocation;
      //
      //e.Item.Cells[this.intEditLinkColumnOrdinal].Controls[INT_ZERO].Visible = false;   
      e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Add(applyimage);
      //
      Literal lit = new Literal();
      lit.Text = "&nbsp;";
      e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Add(lit);
      //     
      System.Web.UI.WebControls.Image cancelimage = new System.Web.UI.WebControls.Image();
      cancelimage.ImageUrl = this.strCancelLinkImageLocation;
      //
      e.Item.Cells[this.intEditLinkColumnOrdinal].Controls[INT_ZERO].Visible = false;
      e.Item.Cells[this.intEditLinkColumnOrdinal].Controls[INT_TWO].Visible = false;
      //
      e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Add(cancelimage);
      //
      applyimage.Attributes.Add(ONCLICK, "document.forms[0]." + this.strHiddenSelectedRowNumber + ".value="+ intItemNumber.ToString() +";document.forms[0]."+ this.strHiddenEditEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count - INT_TWO, true)+"';eval(document.forms[0]."+ this.strHiddenEditEvent +".value);");
      //
      cancelimage.Attributes.Add(ONCLICK, "if(confirm('"+ this.strCancelConfirmationMessage +"')){document.forms[0]." + this.strHiddenSelectedRowNumber + ".value="+ intItemNumber.ToString() +";document.forms[0]."+ this.strHiddenEditEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count - INT_ONE, true)+"';eval(document.forms[0]."+ this.strHiddenEditEvent +".value);}");
      //
      System.Web.UI.WebControls.Image deleteimage = new System.Web.UI.WebControls.Image();
      deleteimage.ImageUrl = this.strDeleteLinkImageLocation;
      e.Item.Cells[this.intDeleteLinkColumnOrdinal].Controls[INT_ZERO].Visible = false;   
      e.Item.Cells[this.intDeleteLinkColumnOrdinal].Controls.Add(deleteimage);
      deleteimage.Attributes.Add(ONCLICK, "if(confirm('"+ this.strDeleteConfirmationMessage +"')){document.forms[0]." + this.strHiddenSelectedRowNumber + ".value="+ intItemNumber.ToString() +";document.forms[0]."+ this.strHiddenDeleteEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count, true)+"'; eval(document.forms[0]."+ this.strHiddenDeleteEvent +".value);}");
      //
      e.Item.Attributes.Add(ONCLICK, this.strDataGridClientIdForJavaScript + "SelectOnSingleClick(" + intItemNumber.ToString() + ", '"+ strCSSClass +"', '"+ this.SelectedItemStyle.CssClass +"', " + this.ClientID + ", 'stylesheet', document.forms[0]." + this.strHiddenSelectedRowNumber + ", document.forms[0]."+ this.strHiddenOldStyleControl +");document.forms[0]."+ this.strHiddenEditEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count - INT_ONE, true)+"';document.forms[0]."+ this.strHiddenDeleteEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, e.Item.Cells[this.intEditLinkColumnOrdinal].Controls.Count, true)+"';");
     #endregion
    }
   }
   else
   {
    //
    e.Item.Attributes.Add(ONCLICK, this.strDataGridClientIdForJavaScript + "SelectOnSingleClick(" + intItemNumber.ToString() + ", '"+ strCSSClass +"', '"+ this.SelectedItemStyle.CssClass +"', " + this.ClientID + ", 'stylesheet', document.forms[0]." + this.strHiddenSelectedRowNumber + ", document.forms[0]."+ this.strHiddenOldStyleControl +");document.forms[0]."+ this.strHiddenEditEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, this.intEditLinkColumnOrdinal, true)+"';document.forms[0]."+ this.strHiddenDeleteEvent +".value='"+this.DefaultPostBackClientSideFunction(intItemNumberForDoubleClick, this.intDeleteLinkColumnOrdinal, true)+"';");
    //e.Item.Attributes.Add(ONCLICK, this.strDataGridClientIdForJavaScript + "SelectOnSingleClick(" + intItemNumber.ToString() + ", '"+ strCSSClass +"', '"+ this.SelectedItemStyle.CssClass +"', " + this.ClientID + ", 'stylesheet', document.forms[0]." + this.strHiddenSelectedRowNumber + ", document.forms[0]."+ this.strHiddenOldStyleControl +");document.forms[0]."+ this.strHiddenEditEvent +".value='"+ DOPOSTBACKCLIENTFUNCTION +"(\\'" + this.ClientID + DOLLAR + UNDERSCORE + CTL + intItemNumberForDoubleClick + DOLLAR + UNDERSCORE + CTL + this.intEditLinkColumnOrdinal + "\\', \\'\\')';document.forms[0]."+ this.strHiddenDeleteEvent +".value='" + DOPOSTBACKCLIENTFUNCTION + "(\\'" + this.ClientID + DOLLAR + UNDERSCORE + CTL + intItemNumberForDoubleClick + DOLLAR + UNDERSCORE + CTL + this.intDeleteLinkColumnOrdinal +"\\', \\'\\')';");
    //
    if(this.blnEditOnDoubleClick)
    {
     e.Item.Attributes.Add(ONDBLCLICK, "eval(document.forms[0]."+ this.strHiddenEditEvent +".value);");
     //e.Item.Attributes.Add(ONDBLCLICK, "__doPostBack('" + this.ClientID + "$_ctl" + intItemNumberForDoubleClick + "$_ctl0', '')");
    }    
   }
  }
  /// <summary>
  /// Registers The Onclick clientside event
  /// </summary>
  /// <param name="e">DataGridItemEventArgs Type which is the source of data</param>  
  private void DeleteLinkButtonOnClickAttribute(DataGridItemEventArgs e)
  {
   if(this.deletetypeDeleteType == deletetype.DeleteWithConfirmation)
   {
    if(e.Item.Cells[INT_ONE].Controls[INT_ZERO] is LinkButton)
    {
     ((LinkButton)e.Item.Cells[INT_ONE].Controls[INT_ZERO]).Attributes.Add(ONCLICK, "return confirm('"+ this.strDeleteConfirmationMessage +"')");
    }
   }  
  }
  /// <summary>
  /// Registers The onClick Clientside Event
  /// </summary>
  /// <param name="e">DataGridItemEventargs type which is the source of the data</param>
  private void CancelLinkButtonOnClickattribute(DataGridItemEventArgs e)
  {
   if(this.canceltypeCancelType == canceltype.CancelWithConfirmation)
   {
    if(e.Item.Cells[INT_ZERO].Controls.Count > INT_ONE )
    {
     if(e.Item.Cells[INT_ZERO].Controls[INT_TWO] is LinkButton)
     {
      ((LinkButton)e.Item.Cells[INT_ZERO].Controls[INT_TWO]).Attributes.Add(ONCLICK, "return confirm('"+ this.strCancelConfirmationMessage +"')");
     }
    }
   }   
  }
  /// <summary>
  /// Validates & Triggers the AlladinDataGridPageRedirect Event
  /// </summary>
  /// <param name="datagriditem">DatagridItem type which is the source of the data</param>
  private void RaisePageRedirectEvent(DataGridItem datagriditem, string strCommandName)
  {
   if(object.Equals(this.AlladinDataGridPageRedirectRow, null))
   {
    throw new ArgumentNullException("AlladinDataGridPageRedirectRow " + EVENTNULL);
   }
   else
   {
    //
    this.UpdateDataRowFromDataGridItem(this.dsGridData.Tables[this.strDataMemberName], datagriditem);
    //
    this.AlladinDataGridPageRedirectRow(this, this.dsGridData, strCommandName);
   }
  }
  /// <summary>
  /// formats the item cells & cell controls
  /// </summary>
  /// <param name="e">DataGridItemEventArgs Type which is the source of data</param>
  /// <param name="datatable">DataTable Type which is the source of data</param>
  private void FormatCellAlignment(DataGridItemEventArgs e, DataTable datatable)
  {
   foreach(DataColumn datacolumn in datatable.Columns)
   {
    #region Adding OnClick ClientSide Event & Setting The Value Of Elipse Button
     //
     if(e.Item.ItemType == ListItemType.EditItem || this.blnFullyEditable)
     {
      if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.ElipseButton], null))
      {
       //
       int ctl = e.Item.ItemIndex + INT_TWO + INT_ONE;
       //
       string strElispseButtonClientSideControlName = this.strDataGridClientIdForJavaScript + UNDERSCORE + CTL + ctl.ToString() + UNDERSCORE + ((TextBox)e.Item.Cells[this.intStartCellFrom].Controls[INT_ZERO]).ClientID;
       //
       HtmlInputButton htmlinputbutton = (HtmlInputButton)e.Item.Cells[this.intStartCellFrom].Controls[INT_TWO];
       //
       htmlinputbutton.Attributes.Add(ONCLICK, this.strElipseButtonClientSideFunction.Replace(TEXTBOXCONTROL, "document.forms[0]."+ strElispseButtonClientSideControlName));
       //       
       htmlinputbutton.Value = this.strElipseButtonDefaultText;
      }    
     }
    #endregion
    #region Setting Alignment Of The Cell
     //
     switch(datacolumn.DataType.ToString())
     {
      case SYSTEMBOOLEAN:
       e.Item.Cells[this.intStartCellFrom].HorizontalAlign = this.horizontalalignBoolean;
       e.Item.Cells[this.intStartCellFrom].VerticalAlign   = this.verticalalignBoolean;
       break;
      case SYSTEMDECIMAL:
       goto case NUMERICFORMAT;
      case SYSTEMINT16:
       goto case NUMERICFORMAT;
      case SYSTEMINT32:
       goto case NUMERICFORMAT;
      case SYSTEMINT64:
       goto case NUMERICFORMAT;
      case SYSTEMDATETIME:
       //
       e.Item.Cells[this.intStartCellFrom].HorizontalAlign = this.horizontalalignDateTime;
       //
       e.Item.Cells[this.intStartCellFrom].VerticalAlign   = this.verticalalignDateTime;
       //
       this.AlignFormControl(e.Item.Cells[this.intStartCellFrom].Controls, this.horizontalalignDateTime.ToString());
       //
       if(this.EditItemIndex == e.Item.ItemIndex || this.blnFullyEditable)
       {
        //
        if(!object.Equals(this.strDatePickerImageLocation, null))
        {
         if(this.strDatePickerImageLocation.Length > INT_ONE)
         {
          ((HtmlImage)e.Item.Cells[this.intStartCellFrom].Controls[INT_TWO]).Src = this.strDatePickerImageLocation;
         }        
        }

        if(!object.Equals(this.strDatePickerClientSideFunction, null))
        {
         if(this.strDatePickerClientSideFunction.Length > INT_ONE)
         {
          //
          int ctl = e.Item.ItemIndex + INT_TWO + INT_ONE;
          //
          string strDatePickerClientSideFunction = this.strDataGridClientIdForJavaScript + UNDERSCORE + CTL + ctl.ToString() + UNDERSCORE + ((TextBox)e.Item.Cells[this.intStartCellFrom].Controls[INT_ZERO]).ClientID;
          //
          ((HtmlImage)e.Item.Cells[this.intStartCellFrom].Controls[INT_TWO]).Attributes.Add(ONCLICK, this.strDatePickerClientSideFunction.Replace(")", "document.forms[0]." + strDatePickerClientSideFunction + ")"));
         }        
        }
        //
       }
       break;
      case SYSTEMSTRING:
       //
       e.Item.Cells[this.intStartCellFrom].HorizontalAlign = this.horizontalalignString;
       //
       e.Item.Cells[this.intStartCellFrom].VerticalAlign   = this.verticalalignString;
       //
       this.AlignFormControl(e.Item.Cells[this.intStartCellFrom].Controls, this.horizontalalignString.ToString());
       //
       break;
      case NUMERICFORMAT:
       //
       e.Item.Cells[this.intStartCellFrom].HorizontalAlign = this.horizontalalignNumeric;
       //
       e.Item.Cells[this.intStartCellFrom].VerticalAlign   = this.verticalalignNumeric;
       //
       this.AlignFormControl(e.Item.Cells[this.intStartCellFrom].Controls, this.horizontalalignNumeric.ToString());
       //
       break;
     }     
    #endregion
    #region Setting the CellWrap
     if(this.blnItemCellWrap)
     {
      e.Item.Cells[this.intStartCellFrom].Wrap = false;
     }
     else
     {
      e.Item.Cells[this.intStartCellFrom].Wrap = true;
     }
    #endregion
    //Incrementing the Member Variable
    ++this.intStartCellFrom;
    ++this.intDataColumnCounter;
   }
   //Re-Inisializing The Member Variable
   this.intStartCellFrom = INT_TWO;
   this.intDataColumnCounter = INT_ZERO;
   }
  /// <summary>
  /// Converts A String InTo Horizontalalign Type 
  /// </summary>
  /// <param name="strData">String type which is the source of data</param>
  /// <param name="horizontalalign">Horzontalalign type which is the source of data</param>
  /// <returns>Horizontalalign Type</returns>
  private HorizontalAlign ConvertStringToAlign(string strData, HorizontalAlign horizontalalign)
  {
   return (HorizontalAlign) TypeDescriptor.GetConverter(horizontalalign).ConvertFrom(strData);
  }
  /// <summary>
  /// Converts A String Into Veritcalalign type
  /// </summary>
  /// <param name="strData">String Type which is the source of data</param>
  /// <param name="verticalalign">Verticalalign type which is the source of data</param>
  /// <returns>Veritcalalign type</returns>
  private VerticalAlign ConvertStringToAlign(string strData, VerticalAlign verticalalign)
  {
   return (VerticalAlign) TypeDescriptor.GetConverter(verticalalign).ConvertFrom(strData); 
  }
  /// <summary>
  /// converts an object of type Datatime into a string
  /// </summary>
  /// <param name="objData">Object of Datetime Type Which is the source of data</param>
  /// <returns>String Type</returns>
  private string ConvertDateTimeToString(object objData)
  {
   if(!object.Equals(objData, DBNull.Value))
   {
    return ((DateTime) objData).ToString(this.strDateFormat);
   }
   else
   {
    return string.Empty;
   }
  }
  /// <summary>
  /// Converts A String To DataTime Type
  /// </summary>
  /// <param name="strData">String Type which is the source of data</param>
  /// <returns>Datetime Type</returns>
  private object ConvertStringToDateTime(string strData)
  {
   if(strData.Length > INT_ZERO)
   {
    return DateTime.ParseExact(strData, this.strDateFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);
   }
   else
   {
    return DBNull.Value;
   }
  }
  /// <summary>
  /// Creates A New DataSet by Iterating through each columns extended properties of the binded datamembbrer
  /// And Seriales That DataSet into a 64bit string. 
  /// </summary>
  /// <returns>String type</returns>
  private string SerializeDataColumnsExtendedProperties()
  {
   //
   DataSet ds = new DataSet(EXTENDEDPROPERTYDATASETNAME);
   //
   ds.Tables.Add(EXTENDEDPROPERTYDATATABLENAME);
   //
   ds.Tables[EXTENDEDPROPERTYDATATABLENAME].Columns.Add(EXTENDEDPROPERTYCOLUMNNAME, System.Type.GetType(SYSTEMSTRING)); 
   ds.Tables[EXTENDEDPROPERTYDATATABLENAME].Columns.Add(EXTENDEDPROPERTYKEY, System.Type.GetType(SYSTEMSTRING));
   ds.Tables[EXTENDEDPROPERTYDATATABLENAME].Columns.Add(EXTENDEDPROPERTYVALUE, System.Type.GetType(SYSTEMSTRING));
   // 
   foreach(DataColumn datacolumn in this.dsGridData.Tables[this.strDataMemberName].Columns)
   {
    //
    IDictionaryEnumerator myEnumerator = datacolumn.ExtendedProperties.GetEnumerator();
    //
    while(myEnumerator.MoveNext())
    {
     //
     DataRow datarow = ds.Tables[EXTENDEDPROPERTYDATATABLENAME].NewRow();
     //
     datarow[EXTENDEDPROPERTYCOLUMNNAME] = datacolumn.ColumnName;
     datarow[EXTENDEDPROPERTYKEY] = myEnumerator.Key.ToString();
     datarow[EXTENDEDPROPERTYVALUE] = myEnumerator.Value.ToString();
     //
     ds.Tables[EXTENDEDPROPERTYDATATABLENAME].Rows.Add(datarow);     
    }
   }
   //   
   if(ds.Tables[EXTENDEDPROPERTYDATATABLENAME].Rows.Count > INT_ZERO)
   {
    return this.SerializeDataSchema((object)ds.GetXml());
   }
   else
   {
    return string.Empty;
   }
  }
  /// <summary>
  /// Deserializes the ExtendedPropertiesDataset and updates the bindeddatamembers each columns extendedproperties.
  /// </summary>
  /// <param name="strDataColumnsExtendedProperties">String Type</param>
  private void DeSerializeDataColumnsExtendedProperties(string strDataColumnsExtendedProperties)
  {
   //
   DataSet ds = this.DeserializeDataSchema(strDataColumnsExtendedProperties, true);     
   //
   foreach(DataColumn datacolumn in this.dsGridData.Tables[this.strDataMemberName].Columns)
   {
    //
    DataRow[] datarowcollection = ds.Tables[EXTENDEDPROPERTYDATATABLENAME].Select(EXTENDEDPROPERTYCOLUMNNAME +"='"+ datacolumn.ColumnName + "'");
    //
    if(datarowcollection.Length > INT_ZERO)
    {
     foreach(DataRow datarow in datarowcollection)
     {
      //
      alladindatagridcelltype alladincelltype = alladindatagridcelltype.EditableControlWidth;  
      //
      alladincelltype = (alladindatagridcelltype) TypeDescriptor.GetConverter(alladincelltype).ConvertFrom(datarow[EXTENDEDPROPERTYKEY].ToString());
      //
      if(datacolumn.ExtendedProperties.ContainsKey(alladincelltype))
      {
       datacolumn.ExtendedProperties[alladincelltype] = datarow[EXTENDEDPROPERTYVALUE].ToString();
      }
      else
      {
       datacolumn.ExtendedProperties.Add(alladincelltype, datarow[EXTENDEDPROPERTYVALUE].ToString());      
      }
     }
    }
   }
  }
  /// <summary>
  /// Compares With The Boolean Value Of Item Cells Mapped With The DataColumn And Removes The Postback Link From The Items And Item Cells
  /// </summary>
  private void FormatGridItems()
  {
   //
   #region Validating And Updating The CheckBoxState Data To Orginal DataTable
    if(this.checkboxstateCheckBoxState == checkboxstate.StateAcrossPages)
    {
     if(this.dsCheckBoxState.Tables.Count > INT_ZERO)
     {
      if(this.dsCheckBoxState.Tables[this.strDataMemberName].Rows.Count > INT_ZERO)
      {
       int intSearchCounter = 0;
       //
       DataColumn[] primarykeycolumn = this.dsGridData.Tables[this.strDataMemberName].PrimaryKey;
       //
       if(primarykeycolumn.Length > INT_ZERO)
       {
        foreach(DataRow datarowUpdate in this.dsGridData.Tables[this.strDataMemberName].Rows)
        {
         foreach(DataRow datarowSearch in this.dsCheckBoxState.Tables[this.strDataMemberName].Rows)
         {
          if(datarowUpdate[primarykeycolumn[INT_ZERO].ColumnName].ToString() == datarowSearch[primarykeycolumn[INT_ZERO].ColumnName].ToString())
          {
           datarowUpdate[this.strCheckBoxStateColumnName] = datarowSearch[this.CheckBoxStateColumnName];   
           intSearchCounter++;
           break;
          }
         }
         if(intSearchCounter == this.dsCheckBoxState.Tables[this.strDataMemberName].Rows.Count)
         {
          break;
         }
        }
       }
       else
       {
        this.RaiseException(new Exception("No Primary key Set For " + this.strDataMemberName + " DataTable.")); 
       }
      }
     }
    }
   #endregion   
   //
   foreach(DataGridItem datagriditem in this.Items)
   {
    #region Validating If PrimaryKey Value Exists And Then Adding A Attribute i.e. ID To Each Item Row.
     //
     DataColumn[] primarykeycolumn = this.dsGridData.Tables[this.strDataMemberName].PrimaryKey;
     //
     if(primarykeycolumn.Length > INT_ZERO)
     {
      datagriditem.Attributes.Add(ITEMID, ((Literal)datagriditem.Cells[primarykeycolumn[0].Ordinal + this.intStartCellFrom].Controls[INT_ZERO]).Text);
     }
    #endregion
    #region Validating The ExntendedProperty For ReadOnlyColumnName
    if(ListItemType.EditItem == datagriditem.ItemType || this.blnFullyEditable)
    {
     //
     foreach(DataColumn datacolumn in this.dsGridData.Tables[this.strDataMemberName].Columns)
     {
      if(!object.Equals(datacolumn.ExtendedProperties[alladindatagridcelltype.ReadOnlyColumnName], null))
      {
       if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(datacolumn.ExtendedProperties[alladindatagridcelltype.ReadOnlyColumnName].ToString()))
       {
        if(this.dsGridData.Tables[this.strDataMemberName].Columns[datacolumn.ExtendedProperties[alladindatagridcelltype.ReadOnlyColumnName].ToString()].DataType.ToString() == SYSTEMBOOLEAN)
        {
         if(((CheckBox) datagriditem.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[datacolumn.ExtendedProperties[alladindatagridcelltype.ReadOnlyColumnName].ToString()].Ordinal + this.intStartCellFrom].Controls[INT_ZERO]).Checked)
         {
          //
          string strDropDownList = string.Empty;           
          //
          foreach(Control control in datagriditem.Cells[datacolumn.Ordinal + this.intStartCellFrom].Controls)
          {
           if(control is TextBox)
           {
            TextBox textbox = ((TextBox)control);
            textbox.ReadOnly = true;
            if(this.strReadOnlyTextBoxCss.Length > INT_ZERO)
            {
             textbox.CssClass = this.strReadOnlyTextBoxCss;
            }
           }
           else if(control is CheckBox)
           {
            CheckBox chk = ((CheckBox)control);
            chk.Enabled = false;
           }
           else if(control is HtmlInputButton)
           {
            HtmlInputButton htmlinputbutton = ((HtmlInputButton)control);
            htmlinputbutton.Visible = false;
           }
           else if(control is HtmlImage)
           {
            HtmlImage htmlimage = ((HtmlImage)control);
            htmlimage.Visible = false;          
           }
           else if(control is DropDownList)
           {
            DropDownList dropdownlist = (DropDownList) control;
            dropdownlist.Visible = false;
            strDropDownList = dropdownlist.Items[dropdownlist.SelectedIndex].Text;
           }
          }
          //
          if(strDropDownList.Length > INT_ZERO)
          {
           //
           TextBox dropdowntextbox = new TextBox();
           //
           dropdowntextbox.Text = strDropDownList;    
           // 
           datagriditem.Cells[datacolumn.Ordinal + this.intStartCellFrom].Controls.Add(dropdowntextbox);
           // 
           dropdowntextbox.CssClass = this.strReadOnlyTextBoxCss;            
          }
         }
        }
        else
        {
         this.RaiseException(new Exception(datacolumn.ExtendedProperties[alladindatagridcelltype.ReadOnlyColumnName].ToString() + " Column Must Be " + SYSTEMBOOLEAN + " Type"));        
        }
       }
       else
       {
        this.RaiseException(new Exception(datacolumn.ExtendedProperties[alladindatagridcelltype.ReadOnlyColumnName].ToString() + " Column Does Not Exits In " + this.strDataMemberName + " DataTable")); 
       }
      }    
     }
    }
    #endregion
    #region Validating If ItemReadOnlyColumnName Is Set To Make An Item Row As Non Editable
     //
     if(this.strItemReadOnlyColumnName.Length > INT_ZERO)
     {
      ///
      if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(this.strItemReadOnlyColumnName))
      {
       //
       if(this.dsGridData.Tables[this.strDataMemberName].Columns[this.strItemReadOnlyColumnName].DataType.ToString() == SYSTEMBOOLEAN)
       {
        //
        if(((CheckBox) datagriditem.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[this.strItemReadOnlyColumnName].Ordinal + this.intStartCellFrom].Controls[INT_ZERO]).Checked)
        {
         //.RemoveAt(INT_ZERO)
         datagriditem.Cells[INT_ZERO].Controls.Clear();        
         //.RemoveAt(INT_ZERO)
         datagriditem.Cells[INT_ONE].Controls.Clear();
         
         if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
         {
          if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(this.strCheckBoxStateColumnName))
          {
           ((CheckBox)datagriditem.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal + this.intStartCellFrom].Controls[INT_ZERO]).Enabled = false;  
          }
         }
         //
         if(this.blnEditOnDoubleClick)
         {
          datagriditem.Attributes.Remove(ONDBLCLICK);
         }
         //
         //datagriditem.Attributes.Remove(ONCLICK);
         //
         if(this.strItemReadOnlyCssClass.Length > INT_ZERO)
         {
          datagriditem.CssClass = this.strItemReadOnlyCssClass;  
         }
         #region Setting The Visibility Property Of Controls To False Apart From Literal Control.
          //
          if(ListItemType.EditItem == datagriditem.ItemType || this.blnFullyEditable)
          {
           //
           DataSet dsDataRowItem = new DataSet();
           //
           dsDataRowItem = this.dsGridData.Clone(); 
           //
           this.UpdateDataRowFromDataGridItem(dsDataRowItem.Tables[this.strDataMemberName], datagriditem);         
           // 
           for(; this.intStartCellFrom < datagriditem.Cells.Count;)
           {
            //
            string strDropDownListSelectedText = string.Empty;
            //
            bool blnCheckControl = false;
            //
            foreach(Control control in datagriditem.Cells[this.intStartCellFrom].Controls)
            {
             if(control is TextBox)
             {
              //
              ((TextBox) control).Visible = false;
             }
             else if(control is DropDownList)
             {
              if(strDropDownListSelectedText.Length == INT_ZERO)
              {
               //
               strDropDownListSelectedText = ((DropDownList) control).Items[((DropDownList) control).SelectedIndex].Text;               
              }
              else
              {
               //
               strDropDownListSelectedText = strDropDownListSelectedText + this.dsGridData.Tables[this.strDataMemberName].Columns[this.intStartCellFrom - INT_TWO].ExtendedProperties[alladindatagridcelltype.DropDownMultipleControlDelimeter].ToString() + ((DropDownList) control).Items[((DropDownList) control).SelectedIndex].Text;
              }
                 //              
              ((DropDownList) control).Visible = false;
             }
             else if(control is CheckBox)
             {
              ((CheckBox) control).Enabled = false;
              blnCheckControl = true;
              //((CheckBox) control).Visible = false;
             }
             else if(control is HtmlInputButton)
             {
              ((HtmlInputButton) control).Visible = false;
             }
             else if(control is HtmlImage)
             {
              ((HtmlImage) control).Visible = false;
             }
             else if(control is Literal)
             {
              ((Literal) control).Visible = false;
             }
            }
            if(!blnCheckControl)
            {
             //
             Literal literal = new Literal();
             //
             if(strDropDownListSelectedText.Length <= INT_ZERO)
             {
              //
              switch(dsDataRowItem.Tables[this.strDataMemberName].Columns[this.intDataColumnCounter].DataType.ToString())
              {
               case SYSTEMDATETIME:
                literal.Text = this.ConvertDateTimeToString(dsDataRowItem.Tables[this.strDataMemberName].Rows[0][this.intDataColumnCounter]);
                break;
               default:
                
                
                literal.Text = dsDataRowItem.Tables[this.strDataMemberName].Rows[0][this.intDataColumnCounter].ToString();
                break;
              }             
             }
             else
             {
              literal.Text = strDropDownListSelectedText;
             }
             //
             datagriditem.Cells[this.intStartCellFrom].Controls.Add(literal);            
            }
            //Incrementing The MemberVariables
            this.intStartCellFrom++;
            this.intDataColumnCounter++;
           }         
           //Decrementing The MemberVariables
           this.intStartCellFrom = INT_TWO;
           this.intDataColumnCounter = INT_ZERO;
          }
         #endregion
         //Incrementing The intReadOnlyItemCount Member Variable
         intReadOnlyItemCount++;
        
        }
       }     
      }
     }    
    #endregion
    #region Validating PersistDataRowInGridItem MemberVariable And Then Adding A Attribute i.e. DataRow To Each Item Row
     //
     if(this.blnPersistDataRowInGridItem)
     {
      DataSet dsDataRowItem = new DataSet();
       dsDataRowItem = this.dsGridData.Clone(); 
      this.UpdateDataRowFromDataGridItem(dsDataRowItem.Tables[this.strDataMemberName], datagriditem);         
      datagriditem.Attributes.Add(DATAROWITEMATTRIBUTE, dsDataRowItem.GetXml());  
     }
    #endregion
    #region Updating The Updated CheckBoxState DataColumn To The ItemCell
     //
     if(this.checkboxstateCheckBoxState == checkboxstate.StateAcrossPages)
     {
      //
      if(this.dsCheckBoxState.Tables.Count > INT_ZERO)
      {
       //
       if(this.dsCheckBoxState.Tables[this.strDataMemberName].Rows.Count > INT_ZERO)
       {
        //
        foreach(Control control in datagriditem.Cells[this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName].Ordinal + this.intStartCellFrom].Controls)
        {
         //
         if(control is CheckBox)
         {
          //
          if(this.dsGridData.Tables[this.strDataMemberName].Rows.Count > INT_ZERO)
          {
           //
           int CurrentRow = datagriditem.ItemIndex + (this.PageSize * this.CurrentPageIndex);
           //
           if(this.dsGridData.Tables[this.strDataMemberName].Rows.Count >= CurrentRow)
           {
            //
            if(this.dsGridData.Tables[this.strDataMemberName].Rows[CurrentRow][this.strCheckBoxStateColumnName] is DBNull)
            {
             ((CheckBox) control).Checked = false;
            }
            else
            {
             ((CheckBox) control).Checked = bool.Parse(this.dsGridData.Tables[this.strDataMemberName].Rows[CurrentRow][this.strCheckBoxStateColumnName].ToString());
            }           
           }           
          }
          //
          break;
         }
        }
       }
      }
     }
    #endregion
   }
  }
  /// <summary>
  /// Creates The Default Client Side PostBack Function Used By ASP.Net
  /// </summary>
  /// <param name="intRowNumber"></param>
  /// <param name="intColumnOrdinal"></param>
  /// <returns></returns>
  private string DefaultPostBackClientSideFunction(int intRowNumber, int intColumnOrdinal, bool blnJavaScript)
  {
   //   
   if(intRowNumber == INT_NEGATIVE_ONE)
   {
    if(this.AllowPaging)
    {
     intRowNumber = (INT_TWO + INT_ONE);
    }
    else
    {
     intRowNumber = INT_TWO;
    }
   }
   //
   if(blnJavaScript)
   {
    return DOPOSTBACKCLIENTFUNCTION + "(\\'" + this.ClientID + DOLLAR + UNDERSCORE + CTL + intRowNumber.ToString() + DOLLAR + UNDERSCORE + CTL + intColumnOrdinal + "\\', \\'\\')";
   }
   else
   {
    return DOPOSTBACKCLIENTFUNCTION + "(\'" + this.ClientID + DOLLAR + UNDERSCORE + CTL + intRowNumber.ToString() + DOLLAR + UNDERSCORE + CTL + intColumnOrdinal + "\', \'\')";
   }
   
  }
  /// <summary>
  /// Iterates The Controls Collection And Sets The Style Alignment Property For Each Control.
  /// </summary>
  /// <param name="controls">Controls Collection Of An Item Cell</param>
  /// <param name="strAlignment">Type Of Alignment For The Control</param>
  private void AlignFormControl(ControlCollection controls, string strAlignment)
  {
   
   foreach(Control control in controls)
   {
    if(control is TextBox)
    {
     ((TextBox)control).Attributes.Add(STYLE, TEXTALIGN + strAlignment); 
     break;
    }
    else if(control is DropDownList)
    {
     ((DropDownList)control).Attributes.Add(STYLE, TEXTALIGN + strAlignment); 
     break;     
    }
   }  
  }
  /// <summary>
  /// Iterates Through The Item Cell of CheckBoxStateDataColumn And Stores It In A DataSet
  /// </summary>
  private void CheckBoxStateDataCollection()
  {
   //
   if(this.checkboxstateCheckBoxState != checkboxstate.NoState)
   {
    if(this.dsCheckBoxState.Tables.Count == INT_ZERO)
    {
     //
     this.dsCheckBoxState = this.dsGridData.Clone();
     //
     this.dsCheckBoxState.Tables[this.strDataMemberName].Columns.Add(PAGENUMBERDATACOLUMN, System.Type.GetType(SYSTEMINT64));    
    }
    else
    {
     //
     DataRow[] datarowCheckBoxStateDelete = this.dsCheckBoxState.Tables[this.strDataMemberName].Select(PAGENUMBERDATACOLUMN + "=" + this.CurrentPageIndex);
     //
     foreach(DataRow datarowDelete in datarowCheckBoxStateDelete)
     {
      this.dsCheckBoxState.Tables[this.strDataMemberName].Rows.Remove(datarowDelete);
     }
    }
    //
    DataRow[] datarowCheckBoxState = this.UpdatedDataSetFromDataGrid().Tables[this.strDataMemberName].Select(this.dsGridData.Tables[this.strDataMemberName].Columns[this.strCheckBoxStateColumnName] + "=true");

    foreach(DataRow datarow in datarowCheckBoxState)
    {
     //
     DataRow datarowNew =  this.dsCheckBoxState.Tables[this.strDataMemberName].NewRow();
     //int intColumnCounter = 0;
     //
     foreach(DataColumn datacolumn in dsCheckBoxState.Tables[this.strDataMemberName].Columns)
     {
      //
      if(this.dsGridData.Tables[this.strDataMemberName].Columns.Contains(datacolumn.ColumnName))
      {
       datarowNew[datacolumn.ColumnName] = datarow[datacolumn.ColumnName]; 
      }
      
      //if(intColumnCounter == dsCheckBoxState.Tables[this.strDataMemberName].Columns.Count - INT_ONE)
      //{
      // break;
      //}
      //
      
      //     
      //intColumnCounter++;
     }
     //
     datarowNew[PAGENUMBERDATACOLUMN] = this.CurrentPageIndex;
     // 
     this.dsCheckBoxState.Tables[this.strDataMemberName].Rows.Add(datarowNew); 
    }
   }   
  }
  #endregion
 }
}

// ----------------------------------------------------------------------------

// Copyright (C) 2004 – 2005 Yasin Alladin

// All rights reserved.

// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE

// ----------------------------------------------------------------------------

/// <summary>

/// File Name: AlladinDataGrid.cs

///<Author>Yasin Alladin</Author>

///<Date> 16-Feb-2005</Date>

///<Description>

using System;

using System.Data;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace Alladin.Controls.DataGrid

{

/// <summary>

/// DataGridTemplate Class Is Used Internal By AlladinDataGridControl Class To Create Template Columns.

/// </summary>

internal class DataGridTemplate: System.Web.UI.ITemplate

{

#region Const Declaration

/// <summary>

/// Defines The Sort String.

/// </summary>

private const string SORT = "sort";

/// <summary>

/// Defines The System Boolean DataType.

/// </summary>

private const string SYSTEMBOOLEAN = "System.Boolean";

/// <summary>

/// Defines The System Decimal DataType.

/// </summary>

private const string SYSTEMDECIMAL = "System.Decimal";

/// <summary>

/// Defines The System Integer 16 DataType.

/// </summary>

private const string SYSTEMINT16 = "System.Int16";

/// <summary>

/// Defines The System Integer 32 DataType.

/// </summary>

private const string SYSTEMINT32 = "System.Int32";

/// <summary>

/// Defines The System Integer 64 DataType.

/// </summary>

private const string SYSTEMINT64 = "System.Int64";

/// <summary>

/// Defines The System DateTime DataType.

/// </summary>

private const string SYSTEMDATETIME = "System.DateTime";

/// <summary>

/// Defines The System String DataType.

/// </summary>

private const string SYSTEMSTRING = "System.String";

/// <summary>

/// Defines The System Numeric Format.

/// </summary>

private const string NUMERICFORMAT = "NumericFormat";

/// <summary>

/// Defines The Signed Integer 1.

/// </summary>

private const int INT_ONE = 1;

/// <summary>

/// Defines The Signed Integer 0.

/// </summary>

private const int INT_ZERO = 0;

/// <summary>

/// Defines The HTML BR Tag.

/// </summary>

private const string BR = "<BR>";

/// <summary>

/// Defines The mailto: KeyWord.

/// </summary>

private const string MAILTO = "mailto:";

/// <summary>

/// Defines The DropDownList Integer ID Delimeter.

/// </summary>

private const string DROPDOWNLISTIDDELIMETER = "_";

#endregion

#region Member Variable Declaration

/// <summary>

/// Stores The Data Of ListItemType.

/// </summary>

private ListItemType listItemType;

/// <summary>

/// Stores The Data Of ColumnName To Be Displayed In The Item Header.

/// </summary>

private string strColumnCaption;

/// <summary>

/// Stores The Data Of The ColumnCaption.

/// </summary>

private int intColumnNumber;

/// <summary>

/// Stores The Data Of DataColumn Name.

/// </summary>

private string strColumnName;

/// <summary>

/// Stores The Data of DataColumnDataType.

/// </summary>

private string strColumnDataType;

/// <summary>

/// Stores The Data Of AllowSorting.

/// </summary>

private bool blnAllowSorting;

/// <summary>

/// Stores The Data Of FullyEditable DataGrid.

/// </summary>

private bool blnFullyEditable;

/// <summary>

/// Stores The Data Of AllowNull.

/// </summary>

private bool blnAllowNull;

/// <summary>

/// Stores The Data Of The Maxlength.

/// </summary>

private int intMaxLength;

/// <summary>

/// Stores The Data Of The DateFormat.

/// </summary>

private string strDateFormat;

/// <summary>

/// Stores The Data Of The ChildDataSet.

/// </summary>

private DataSet childdataset;

/// <summary>

/// Stores The Data Of Datacolumns ExtendtedProperties Collection.

/// </summary>

private PropertyCollection propertycollectionColumnExtendedProperties;

/// <summary>

/// Stores The Data Of RequiredFieldValidator Default Message.

/// </summary>

private string strRequiredFieldValidatorDefaultMessage;

/// <summary>

/// Stores The Data Of RangeValidator Default Decimal Min Value.

/// </summary>

private string strRangeValidatorDefaultMessage;

/// <summary>

/// Stores The Data Of RangeValidator Default Decimal Min Value.

/// </summary>

private string strRangeValidatorDefaultDecimalMinValue;

/// <summary>

/// Stores The Data Of RangeValidator Default Decimal Max Value.

/// </summary>

private string strRangeValidatorDefaultDecimalMaxValue;

/// <summary>

/// Stores The Data Of RangeValidator Default Integer Min Value.

/// </summary>

private string strRangeValidatorDefaultIntegerMinValue;

/// <summary>

/// Stores The Data Of RangeValidator Default Integer Max Value.

/// </summary>

private string strRangeValidatorDefaultIntegerMaxValue;

/// <summary>

/// Stores The Data Of DataColumn.

/// </summary>

private bool blnDataColumnReadOnly;

/// <summary>

/// Stores The Data Of ValidationDatatype.

/// </summary>

private ValidationDataType validationdatatype;

/// <summary>

/// Stores The Data Of EmailUrlColumnOrdinal.

/// </summary>

private int intEmailUrlColumnOrdinal;

/// <summary>

/// Stores The Data Of ReadOnlyTextBoxCss.

/// </summary>

private string strReadOnlyTextBoxCss;

/// <summary>

/// Stores The Data Of DateControl textBox Type.

/// </summary>

private AlladinDataGrid.textboxtype textboxtypeDateControl;

/// <summary>

/// Stores The Data Of ElipseButtonControl textBox Type.

/// </summary>

private AlladinDataGrid.textboxtype textboxtypeElipseButtonControl;

/// <summary>

/// Stores The Data of The Checkboxstate Enumerator.

/// </summary>

private AlladinDataGrid.checkboxstate checkboxstateCheckBoxState;

/// <summary>

/// Stores The Data Of The CheckboxColumnName To Be Persisted.

/// </summary>

private string strCheckBoxStateColumnName;

#endregion

#region Public Method Of The Class

/// <summary>

/// This Is The Contructor Of the Class Which Gets Fired When The Class is Instainated.

/// </summary>

/// <param name="listItemType">Type Of Template Colume.</param>

/// <param name="datacolumn">Datacolumn Attached With This Template Column.</param>

/// <param name="blnAllowSorting">Allowing Sorting Is Enabled Or Not.</param>

/// <param name="blnFullyEditable">Grid Is FullyEditable Or Inline.</param>

/// <param name="strDateFormat">DateFormat Of The Grid.</param>

/// <param name="childdataset">DataSet Which Is Used For Populating DropDownList Control.</param>

/// <param name="strRequiredFieldValidatorDefaultMessage">RequiredFieldValidator Error Message.</param>

/// <param name="strRangeValidatorDefaultMessage">RangeFieldValidator Error Message.</param>

/// <param name="strRangeValidatorDefaultDecimalMinValue">RangeFieldValidator Decimal Min Value.</param>

/// <param name="strRangeValidatorDefaultDecimalMaxValue">RangeFieldValidator Decimal Max Value.</param>

/// <param name="strRangeValidatorDefaultIntegerMinValue">RangeFieldValidator Integar Min Value.</param>

/// <param name="strRangeValidatorDefaultIntegerMaxValue">RangeFieldValidator Integer Max Value.</param>

/// <param name="intEmailUrlColumnOrdinal">Column Number In The DataTable For Adding Email Address.</param>

/// <param name="strReadOnlyTextBoxCss">ReadOnlyTextBox Css Name.</param>

/// <param name="textboxtypeDateControl">DateControl Is ReadOnly Or Editable.</param>

/// <param name="textboxtypeElipseButtonControl">ElipseButton Is ReadOnly Or Editable.</param>

/// <param name="checkboxstateCheckBoxState">CheckBoxState Is Maintained Across Pages Or No.</param>

/// <param name="strCheckBoxStateColumnName">ChechBoxState Column Name.</param>

public DataGridTemplate(ListItemType listItemType, DataColumn datacolumn, bool blnAllowSorting, bool blnFullyEditable, string strDateFormat, DataSet childdataset, string strRequiredFieldValidatorDefaultMessage, string strRangeValidatorDefaultMessage, string strRangeValidatorDefaultDecimalMinValue, string strRangeValidatorDefaultDecimalMaxValue, string strRangeValidatorDefaultIntegerMinValue, string strRangeValidatorDefaultIntegerMaxValue, int intEmailUrlColumnOrdinal, string strReadOnlyTextBoxCss, AlladinDataGrid.textboxtype textboxtypeDateControl, AlladinDataGrid.textboxtype textboxtypeElipseButtonControl, AlladinDataGrid.checkboxstate checkboxstateCheckBoxState, string strCheckBoxStateColumnName)

{

this.listItemType = listItemType;

this.strColumnCaption = datacolumn.Caption;

this.strColumnName = datacolumn.ColumnName;

this.intColumnNumber = datacolumn.Ordinal;

this.blnDataColumnReadOnly = datacolumn.ReadOnly;

this.blnAllowSorting = blnAllowSorting;

this.strColumnDataType = datacolumn.DataType.ToString();

this.blnFullyEditable = blnFullyEditable;

this.blnAllowNull = datacolumn.AllowDBNull;

this.intMaxLength = datacolumn.MaxLength;

this.strDateFormat = strDateFormat;

this.childdataset = childdataset;

this.propertycollectionColumnExtendedProperties = datacolumn.ExtendedProperties;

this.strRequiredFieldValidatorDefaultMessage = strRequiredFieldValidatorDefaultMessage;

this.strRangeValidatorDefaultMessage = strRangeValidatorDefaultMessage;

this.strRangeValidatorDefaultDecimalMinValue = strRangeValidatorDefaultDecimalMinValue;

this.strRangeValidatorDefaultDecimalMaxValue = strRangeValidatorDefaultDecimalMaxValue;

this.strRangeValidatorDefaultIntegerMinValue = strRangeValidatorDefaultIntegerMinValue;

this.strRangeValidatorDefaultIntegerMaxValue = strRangeValidatorDefaultIntegerMaxValue;

this.intEmailUrlColumnOrdinal = intEmailUrlColumnOrdinal;

this.strReadOnlyTextBoxCss = strReadOnlyTextBoxCss;

this.textboxtypeDateControl = textboxtypeDateControl;

this.textboxtypeElipseButtonControl = textboxtypeElipseButtonControl;

this.checkboxstateCheckBoxState = checkboxstateCheckBoxState;

this.strCheckBoxStateColumnName = strCheckBoxStateColumnName;

}

/// <summary>

/// This Method Gets Fired Internally By The DataGrid Control And Adds The Appropriate Template Columns.

/// </summary>

/// <param name="container">Container Of The Column Which Contains SubControl or ChildControls.</param>

public void InstantiateIn(System.Web.UI.Control container)

{

switch(this.listItemType)

{

case ListItemType.Header:

if(this.blnAllowSorting)

{

//

LinkButton linkbutton = new LinkButton();

//

switch(this.strColumnDataType)

{

case SYSTEMBOOLEAN:

if(this.checkboxstateCheckBoxState == AlladinDataGrid.checkboxstate.NoState)

{

#region Adding LinkButton Control

linkbutton.Text = this.strColumnCaption;

linkbutton.CommandName = SORT;

linkbutton.CommandArgument = strColumnName;

container.Controls.Add(linkbutton);

#endregion

}

else

{

if(this.strColumnName != this.strCheckBoxStateColumnName)

{

#region Adding LinkButton Control

linkbutton.Text = this.strColumnCaption;

linkbutton.CommandName = SORT;

linkbutton.CommandArgument = strColumnName;

container.Controls.Add(linkbutton);

#endregion

}

else

{

#region Adding CheckBox Control

if(this.strColumnName == this.strCheckBoxStateColumnName)

{

CheckBox hedchk = new CheckBox();

hedchk.Enabled = true;

container.Controls.Add(hedchk);

}

#endregion

}

}

break;

default:

#region Adding Literal Control

linkbutton.Text = this.strColumnCaption;

linkbutton.CommandName = SORT;

linkbutton.CommandArgument = strColumnName;

container.Controls.Add(linkbutton);

#endregion

break;

}

}

else

{

//

Literal literal = new Literal();

//

switch(this.strColumnDataType)

{

case SYSTEMBOOLEAN:

if(this.checkboxstateCheckBoxState == AlladinDataGrid.checkboxstate.NoState)

{

#region Adding Literal Control

literal.Text = this.strColumnCaption;

container.Controls.Add(literal);

#endregion

}

else

{

 

if(this.strColumnName == this.strCheckBoxStateColumnName)

{

#region Adding CheckBox Control

CheckBox hedchk = new CheckBox();

hedchk.Enabled = true;

container.Controls.Add(hedchk);

#endregion

}

else

{

#region Adding Literal Control

literal.Text = this.strColumnCaption;

container.Controls.Add(literal);

#endregion

}

}

break;

default:

#region Adding Literal Control

literal.Text = this.strColumnCaption;

container.Controls.Add(literal);

#endregion

break;

}

}

break;

case ListItemType.Footer:

break;

case ListItemType.Item:

if(this.blnFullyEditable)

{

//Calling Helper Function

this.EditTemplateControl(container);

}

else

{

if(!object.Equals(this.propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.EmailHyperLink], null))

{

#region Adding HyperLink

HyperLink hyperlinkEmail = new HyperLink();

hyperlinkEmail.DataBinding +=new EventHandler(hyperlinkEmail_DataBinding);

container.Controls.Add(hyperlinkEmail);

#endregion

}

else if(!object.Equals(this.propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.LinkButton], null))

{

#region Adding LinkButton

LinkButton linkbutton = new LinkButton();

linkbutton.CommandName = this.strColumnName;

linkbutton.CommandArgument = linkbutton.ToString();

linkbutton.DataBinding +=new EventHandler(linkbutton_DataBinding);

container.Controls.Add(linkbutton);

#endregion

}

else

{

switch(this.strColumnDataType)

{

case SYSTEMBOOLEAN:

#region Adding CheckBox Control

CheckBox chk = new CheckBox();

if(this.checkboxstateCheckBoxState == AlladinDataGrid.checkboxstate.NoState)

{

chk.Enabled = false;

}

else

{

if(this.strColumnName == this.strCheckBoxStateColumnName)

{

chk.Enabled = true;

}

else

{

chk.Enabled = false;

}

}

chk.DataBinding +=new EventHandler(chk_DataBinding);

container.Controls.Add(chk);

#endregion

break;

default:

#region Adding Literal Control

Literal literal1 = new Literal();

literal1.DataBinding +=new EventHandler(literal_DataBinding);

container.Controls.Add(literal1);

#endregion

break;

}

}

}

break;

case ListItemType.EditItem :

this.EditTemplateControl(container);

break;

}

}

#endregion

#region DataBinding Events Of Controls

/// <summary>

/// This Event Binds The DataRow Value For This DataColumn To The Literal Control.

/// </summary>

/// <param name="sender">Literal Control.</param>

/// <param name="e">EventArgs Is Empty.</param>

private void literal_DataBinding(object sender, EventArgs e)

{

Literal literal = (Literal) sender;

System.Data.DataRowView container = (System.Data.DataRowView) ((DataGridItem)literal.NamingContainer).DataItem;

 

switch(this.strColumnDataType)

{

case SYSTEMDATETIME:

literal.Text = this.ConvertDateTimeToString(container.Row.ItemArray[this.intColumnNumber]);

break;

default:

literal.Text = container.Row.ItemArray[this.intColumnNumber].ToString();

break;

}

}

/// <summary>

/// This Event Binds The DataRow Value For This DataColumn To The CheckBox Control.

/// </summary>

/// <param name="sender">Checkbox Control.</param>

/// <param name="e">EventArgs Is Empty.</param>

private void chk_DataBinding(object sender, EventArgs e)

{

CheckBox chk = (CheckBox) sender;

System.Data.DataRowView container = (System.Data.DataRowView) ((DataGridItem)chk.NamingContainer).DataItem;

if(container.Row.ItemArray[this.intColumnNumber] is DBNull)

{

chk.Checked = false;

}

else

{

chk.Checked = (bool)container.Row.ItemArray[this.intColumnNumber];

}

}

/// <summary>

/// This Event Binds The DataRow Value For This DataColumn To The Textbox Control.

/// </summary>

/// <param name="sender">TextBox Control.</param>

/// <param name="e">EventArgs Is Empty.</param>

private void textbox_DataBinding(object sender, EventArgs e)

{

TextBox textbox = (TextBox) sender;

System.Data.DataRowView container = (System.Data.DataRowView) ((DataGridItem)textbox.NamingContainer).DataItem;

//

switch(this.strColumnDataType)

{

case SYSTEMDATETIME:

textbox.Text = this.ConvertDateTimeToString(container.Row.ItemArray[this.intColumnNumber]);

break;

case SYSTEMDECIMAL:

goto case NUMERICFORMAT;

case SYSTEMINT16:

goto case NUMERICFORMAT;

case SYSTEMINT32:

goto case NUMERICFORMAT;

case SYSTEMINT64:

goto case NUMERICFORMAT;

case NUMERICFORMAT:

textbox.Text = container.Row.ItemArray[this.intColumnNumber].ToString();

break;

case SYSTEMSTRING:

textbox.Text = container.Row.ItemArray[this.intColumnNumber].ToString();

break;

default:

textbox.Text = container.Row.ItemArray[this.intColumnNumber].ToString();

break;

}

}

/// <summary>

/// This Event Binds The DataRow Value For This DataColumn To The Email HyperLink Control.

/// </summary>

/// <param name="sender">HyperLink Control.</param>

/// <param name="e">EventArgs Is Empty.</param>

private void hyperlinkEmail_DataBinding(object sender, EventArgs e)

{

HyperLink hyperlinkEmail = (HyperLink) sender;

System.Data.DataRowView container = (System.Data.DataRowView) ((DataGridItem)hyperlinkEmail.NamingContainer).DataItem;

string strData = container.Row.ItemArray[this.intColumnNumber].ToString();

//

if(this.intEmailUrlColumnOrdinal >= INT_ZERO)

{

hyperlinkEmail.NavigateUrl = MAILTO + container.Row.ItemArray[this.intEmailUrlColumnOrdinal].ToString();

}

else

{

hyperlinkEmail.NavigateUrl = MAILTO + strData;

}

//

hyperlinkEmail.Text = strData;

}

 

/// <summary>

/// This Event Binds The DataRow Value For This DataColumn To The LinkButton Control.

/// </summary>

/// <param name="sender">LinkButton Control.</param>

/// <param name="e">EventArgs Is Empty.</param>

private void linkbutton_DataBinding(object sender, EventArgs e)

{

LinkButton linkbutton = (LinkButton) sender;

System.Data.DataRowView container = (System.Data.DataRowView) ((DataGridItem)linkbutton.NamingContainer).DataItem;

linkbutton.Text = container.Row.ItemArray[this.intColumnNumber].ToString();

}

 

/// <summary>

/// This Event Binds The DataRow Value For This DataColumn To The DropDownList Control.

/// </summary>

/// <param name="sender">DropDownList Control.</param>

/// <param name="e">EventArgs Is Empty.</param>

private void dropdownlist_DataBinding(object sender, EventArgs e)

{

if(!object.Equals(this.childdataset, null))

{

//

DropDownList dropdownlist = (DropDownList) sender;

//

System.Data.DataRowView container = (System.Data.DataRowView) ((DataGridItem)dropdownlist.NamingContainer).DataItem;

//

string strTextField = string.Empty;

//

string strValueField = string.Empty;

//

string[] strData;

//

DataTable childdatatable;

//

string[] strIdSpliter = dropdownlist.ID.Split(DROPDOWNLISTIDDELIMETER.ToCharArray());

//

string strTableName = strIdSpliter[strIdSpliter.GetUpperBound(INT_ZERO)];

//

childdatatable = this.childdataset.Tables[strTableName];

//

if(propertycollectionColumnExtendedProperties.Count == INT_ZERO)

{

throw new Exception(this.strColumnName + "'s DropDownList Cannot be Binded As No DataTextField & DataValueField Set");

}

else

{

//

if(object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownMultipleControlDelimeter], null))

{

//

strTextField = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownListDataTextField].ToString();

//

strValueField = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownListDataValueField].ToString();

}

else

{

//

string[] strTextSpliter = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownListDataTextField].ToString().Split(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownMultipleControlDelimeter].ToString().ToCharArray());

//

string[] strValueSpliter = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownListDataValueField].ToString().Split(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownMultipleControlDelimeter].ToString().ToCharArray());

//

foreach(string strText in strTextSpliter)

{

if(childdatatable.Columns.Contains(strText))

{

strTextField = strText;

//

break;

}

}

//

foreach(string strValue in strValueSpliter)

{

if(childdatatable.Columns.Contains(strValue))

{

strValueField = strValue;

//

break;

}

}

}

//

string strDefaultTextField = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownListDefaultTextField].ToString();

//

if(strTextField.Length == INT_ZERO || strValueField.Length == INT_ZERO)

{

throw new Exception(this.strColumnName + "'s DropDownList Cannot be Binded As No Text & Value Field Set");

}

//

if(object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownMultipleControlDelimeter], null))

{

//

strData = new string[1];

//

strData[0] = container.Row.ItemArray[this.intColumnNumber].ToString();

}

else

{

strData = container.Row.ItemArray[this.intColumnNumber].ToString().Split(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.DropDownMultipleControlDelimeter].ToString().ToCharArray());

}

//

dropdownlist.Items.Add(new ListItem(strDefaultTextField, ""));

//

int intDropDownCounter = INT_ONE;

//

foreach(DataRow datarow in childdatatable.Rows)

{

//

dropdownlist.Items.Add(new ListItem(datarow[strTextField].ToString(), datarow[strValueField].ToString()));

//

for(int intDataCount = 0; intDataCount < strData.Length; intDataCount++)

{

//

if(datarow[strTextField].ToString().Trim().ToLower() == strData[intDataCount].Trim().ToLower() || datarow[strValueField].ToString().Trim().ToLower() == strData[intDataCount].Trim().ToLower())

{

dropdownlist.SelectedIndex = intDropDownCounter;

}

}

//

intDropDownCounter++;

}

}

}

}

#endregion

#region Validator Control Methods

/// <summary>

/// This Helper Method Adds RequiredFieldValidator To The template Columns Controls Collection.

/// </summary>

/// <param name="container">Controls Collection.</param>

/// <param name="strControlToValidate">Name Of The Control To Validate.</param>

private void RequiredFieldValidator(Control container, string strControlToValidate)

{

RequiredFieldValidator rfv = new RequiredFieldValidator();

rfv.Display = ValidatorDisplay.Dynamic;

rfv.Text = BR + this.strRequiredFieldValidatorDefaultMessage;

rfv.ControlToValidate = strControlToValidate;

container.Controls.Add(rfv);

}

/// <summary>

/// This Helper Method Adds RangeFieldValidator To The template Columns Controls Collection.

/// </summary>

/// <param name="container">Controls Collection.</param>

/// <param name="strControlToValidate">Name Of The Control To Validate.</param>

/// <param name="blnDataColumnType">DataType Of The Control To Validate.</param>

private void RangeFieldValidator(Control container, string strControlToValidate, bool blnDataColumnType)

{

//

RangeValidator rv = new RangeValidator();

//

rv.Display = ValidatorDisplay.Dynamic;

//

rv.Text = BR + this.strRangeValidatorDefaultMessage;

//

rv.ControlToValidate = strControlToValidate;

//

if(blnDataColumnType)

{

//

switch(this.strColumnDataType)

{

case SYSTEMDECIMAL:

rv.Type = ValidationDataType.Double;

rv.MinimumValue = this.strRangeValidatorDefaultDecimalMinValue;

rv.MaximumValue = this.strRangeValidatorDefaultDecimalMaxValue;

//

container.Controls.Add(rv);

break;

case SYSTEMINT16:

rv.Type = ValidationDataType.Integer;

rv.MinimumValue = this.strRangeValidatorDefaultIntegerMinValue;

rv.MaximumValue = this.strRangeValidatorDefaultIntegerMaxValue;

//

container.Controls.Add(rv);

break;

case SYSTEMINT32:

rv.Type = ValidationDataType.Integer;

rv.MinimumValue = this.strRangeValidatorDefaultIntegerMinValue;

rv.MaximumValue = this.strRangeValidatorDefaultIntegerMaxValue;

//

container.Controls.Add(rv);

break;

case SYSTEMINT64:

rv.Type = ValidationDataType.Integer;

rv.MinimumValue = this.strRangeValidatorDefaultIntegerMinValue;

rv.MaximumValue = this.strRangeValidatorDefaultIntegerMaxValue;

//

container.Controls.Add(rv);

break;

}

}

else

{

rv.Type = this.validationdatatype;

rv.MinimumValue = this.strRangeValidatorDefaultIntegerMinValue;

rv.MaximumValue = this.strRangeValidatorDefaultIntegerMaxValue;

//

container.Controls.Add(rv);

}

}

/// <summary>

/// This Helper Method Adds RegularExpressionValidator To The template Columns Controls Collection.

/// </summary>

/// <param name="container">Controls Collection.</param>

/// <param name="strControlToValidate">Name Of The Control To Validate.</param>

/// <param name="strValidationExpression">ReX expression.</param>

private void RegularExpressionValidator(Control container, string strControlToValidate, string strValidationExpression)

{

RegularExpressionValidator rev = new RegularExpressionValidator();

rev.Display = ValidatorDisplay.Dynamic;

rev.Text = BR + this.strRequiredFieldValidatorDefaultMessage;

rev.ControlToValidate = strControlToValidate;

rev.ValidationExpression = strValidationExpression;

container.Controls.Add(rev);

}

/// <summary>

/// This Helper Method Adds CustomValidator To The template Columns Controls Collection.

/// </summary>

/// <param name="container">Controls Collection.</param>

/// <param name="strControlToValidate">Name Of The Control To Validate.</param>

/// <param name="strClientValidationFunction">Client Side JavaScript Function Name.</param>

private void CustomValidator(Control container, string strControlToValidate, string strClientValidationFunction)

{

CustomValidator cv = new CustomValidator();

cv.Display = ValidatorDisplay.Dynamic;

cv.Text = BR + this.strRequiredFieldValidatorDefaultMessage;

cv.ControlToValidate = strControlToValidate;

cv.ClientValidationFunction = strClientValidationFunction;

container.Controls.Add(cv);

}

#endregion

#region Helper Method

/// <summary>

/// This Helper Method Adds Editable Child Controls To The Controls Collection.

/// </summary>

/// <param name="container">Controls Collection Which Contains Child Control.</param>

private void EditTemplateControl(System.Web.UI.Control container)

{

//

string strControlToValidate;

//

if(this.blnDataColumnReadOnly)

{

#region Adding Literal Control

Literal literal = new Literal();

literal.DataBinding +=new EventHandler(literal_DataBinding);

container.Controls.Add(literal);

#endregion

}

else if(!object.Equals(this.propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.ElipseButton], null))

{

#region Adding An ElipseButtonControl

//

TextBox elipsebuttontextbox = new TextBox();

//

elipsebuttontextbox.ID = "txt" + this.strColumnName;

//

if(this.intMaxLength > -1)

{

elipsebuttontextbox.MaxLength = this.intMaxLength;

}

//

if(this.textboxtypeElipseButtonControl == AlladinDataGrid.textboxtype.ReadOnly)

{

elipsebuttontextbox.ReadOnly = true;

//

if(this.strReadOnlyTextBoxCss.Length > INT_ZERO)

{

elipsebuttontextbox.CssClass = this.strReadOnlyTextBoxCss;

}

}

//

elipsebuttontextbox.DataBinding +=new EventHandler(textbox_DataBinding);;

//

strControlToValidate = elipsebuttontextbox.ID;

//

container.Controls.Add(elipsebuttontextbox);

//

Literal literal = new Literal();

literal.ID = "lit" + this.strColumnName;

literal.Text = "&nbsp";

//

container.Controls.Add(literal);

//

System.Web.UI.HtmlControls.HtmlInputButton elipsebuttonhtmlbutton = new System.Web.UI.HtmlControls.HtmlInputButton();

//

elipsebuttonhtmlbutton.ID = "btn" + this.strColumnName;

//

container.Controls.Add(elipsebuttonhtmlbutton);

if(!this.blnAllowNull)

{

this.RequiredFieldValidator(container, strControlToValidate);

}

#endregion

}

else

{

//

switch(this.strColumnDataType)

{

case SYSTEMBOOLEAN:

#region Adding checkbox control

CheckBox chk = new CheckBox();

chk.DataBinding +=new EventHandler(chk_DataBinding);

container.Controls.Add(chk);

#endregion

break;

case SYSTEMDATETIME:

#region Adding A DateTimeControl

//

TextBox datetimetextbox = new TextBox();

//

datetimetextbox.ID = "txt" + this.strColumnName;

//

if(this.textboxtypeDateControl == AlladinDataGrid.textboxtype.ReadOnly)

{

//

datetimetextbox.ReadOnly = true;

//

if(this.strReadOnlyTextBoxCss.Length > INT_ZERO)

{

datetimetextbox.CssClass = this.strReadOnlyTextBoxCss;

}

}

//

datetimetextbox.DataBinding +=new EventHandler(textbox_DataBinding);

//

strControlToValidate = datetimetextbox.ID;

//

container.Controls.Add(datetimetextbox);

//

Literal literal = new Literal();

//

literal.ID = "lit" + this.strColumnName;

//

literal.Text = "&nbsp";

//

container.Controls.Add(literal);

//

System.Web.UI.HtmlControls.HtmlImage htmlimage = new System.Web.UI.HtmlControls.HtmlImage();

//

htmlimage.ID = "img" + this.strColumnName;

//

container.Controls.Add(htmlimage);

if(!this.blnAllowNull)

{

this.RequiredFieldValidator(container, strControlToValidate);

}

#endregion

break;

default:

if(object.Equals(this.childdataset, null))

{

#region Adding Textbox Control

//

TextBox textbox = new TextBox();

//

textbox.ID = this.strColumnName;

//

textbox.DataBinding +=new EventHandler(textbox_DataBinding);

//

if(this.intMaxLength > -1)

{

textbox.MaxLength = this.intMaxLength;

}

//

strControlToValidate = textbox.ID;

//

container.Controls.Add(textbox);

if(!this.blnAllowNull)

{

this.RequiredFieldValidator(container, strControlToValidate);

}

//

this.RangeFieldValidator(container, strControlToValidate, true);

#endregion

 

}

else

{

#region Adding DropDownList

foreach(DataTable datatable in childdataset.Tables)

{

//

//this.childdatatable = datatable;

//

DropDownList dropdownlist = new DropDownList();

//

dropdownlist.ID = this.strColumnName + DROPDOWNLISTIDDELIMETER + datatable.TableName;

//

dropdownlist.DataBinding +=new EventHandler(dropdownlist_DataBinding);

//

strControlToValidate = dropdownlist.ID;

//

container.Controls.Add(dropdownlist);

//

if(!this.blnAllowNull)

{

this.RequiredFieldValidator(container, strControlToValidate);

}

}

#endregion

}

//

break;

}

}

//

if(!object.Equals(this.propertycollectionColumnExtendedProperties, null))

{

//Calling The Helper Function

this.ProcessExtendedProperties(container);

}

}

/// <summary>

/// This Helper Method Converts An DataRow Value Into A Valid DateTime String Based On The DateTime Format.

/// </summary>

/// <param name="objData">ADO.Net DataRow Value</param>

/// <returns>Valid Formated DateTime String.</returns>

private string ConvertDateTimeToString(object objData)

{

if(object.Equals(objData, DBNull.Value))

{

return string.Empty;

}

else

{

return ((DateTime) objData).ToString(this.strDateFormat);

}

}

/// <summary>

/// This Helper Method Converts A String To A DateTime Based On The DateFormat.

/// </summary>

/// <param name="strData">String Data.</param>

/// <returns>DateTime Data</returns>

private DateTime ConvertStringToDateTime(string strData)

{

return DateTime.ParseExact(strData, this.strDateFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);

}

/// <summary>

/// This Helper Method Iterates All The ExtendedProperties Of a DataColumn And Formats The Child Controls Of That Column.

/// </summary>

/// <param name="container">Controls Collection.</param>

private void ProcessExtendedProperties(System.Web.UI.Control container)

{

#region Adding The Width Of TextBox & DropDownList From Extended Properties

foreach(Control control in container.Controls)

{

//

if(control is TextBox)

{

//

if(!object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.EditableControlWidth], null))

{

((TextBox)control).Width = Unit.Parse(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.EditableControlWidth].ToString());

}

}

else if(control is DropDownList)

{

//

if(!object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.EditableControlWidth], null))

{

((DropDownList)control).Width = Unit.Parse(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.EditableControlWidth].ToString());

}

}

}

#endregion

#region Adding RequiredFieldValidator Control From Extended Properties

//

if(!object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RequiredFieldValidator], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RequiredFieldValidatorMessage], null))

{

//

this.strRequiredFieldValidatorDefaultMessage = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RequiredFieldValidatorMessage].ToString();

//

if(container.Controls[INT_ZERO] is TextBox)

{

this.RequiredFieldValidator(container, ((TextBox)container.Controls[INT_ZERO]).ID);

}

else if(container.Controls[INT_ZERO] is DropDownList)

{

this.RequiredFieldValidator(container, ((DropDownList)container.Controls[INT_ZERO]).ID);

}

}

#endregion

#region Adding RangeValidator Control From Extended Properties

if(!object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RequiredFieldValidator], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorMessage], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorType], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorMinValue], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorMaxValue], null))

{

//

this.strRequiredFieldValidatorDefaultMessage = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorMessage].ToString();

//

this.validationdatatype = (ValidationDataType) System.ComponentModel.TypeDescriptor.GetConverter(validationdatatype).ConvertFrom(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorType].ToString());

//

this.strRangeValidatorDefaultIntegerMinValue = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorMinValue].ToString();

//

this.strRangeValidatorDefaultIntegerMaxValue = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RangeValidatorMaxValue].ToString();

//

if(container.Controls[INT_ZERO] is TextBox)

{

this.RangeFieldValidator(container, ((TextBox)container.Controls[INT_ZERO]).ID, false);

}

}

#endregion

#region Adding RegularExpressionValidator Control From Extended Properties

if(!object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RegularExpressionValidator], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RegularExpressionValidatorMessage], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RegularExpressionValidatorValidationExpression], null))

{

//

this.strRequiredFieldValidatorDefaultMessage = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RegularExpressionValidatorMessage].ToString();

//

if(container.Controls[INT_ZERO] is TextBox)

{

this.RegularExpressionValidator(container, ((TextBox)container.Controls[INT_ZERO]).ID, propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.RegularExpressionValidatorValidationExpression].ToString());

}

}

#endregion

#region Adding CustomValidator Control From Extended Properties

if(!object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.CustomFieldValidator], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.CustomFieldValidatorMessage], null) && !object.Equals(propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.CustomFieldValidatorClientValidationFunction], null))

{

//

this.strRequiredFieldValidatorDefaultMessage = propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.CustomFieldValidatorMessage].ToString();

//

if(container.Controls[INT_ZERO] is TextBox)

{

this.CustomValidator(container, ((TextBox)container.Controls[INT_ZERO]).ID, propertycollectionColumnExtendedProperties[AlladinDataGrid.alladindatagridcelltype.CustomFieldValidatorClientValidationFunction].ToString());

}

}

#endregion

}

#endregion

}

}