Tuesday, June 29, 2004
Meta Reunion
I would love to do this with my associations with other organizations too viz.: Genesys & Mediline, oneway it helps get a feedback of oneself on how you treated your team and vice-versa.
Well there is a community created on Orkut called Meta Alumni. If you have not received my invitation, do ping me.
Tuesday, June 22, 2004
Break through firewall
No configuration hassles, no techie-talk or geek-speak. Not only does hopster configure itself, it even knows how to configure Kazaa, MSN Messenger and many others - so you don't need to.
Once installed, hopster operates silently in the background, you won't even notice it's there.
Hopster was designed with the most popular applications in mind: MSN Messenger, ICQ, Yahoo Messenger, Trillian... no matter where your friends are, hopster gets you there. And so are they adding more apps every day.
Hopster also protects you from the nosy Bad Guys on the 'net.
It hides your actual ip address, making it impossible for hackers to trace you. And their firewalls protect you from unwanted visitors.
Download Now
On downloading the demo version, if you get annonyed with the ad bar right click on the title bar and click minimize, this will hide the ad bar for ever and you don't need to buy it unless you need more than 4kb/sec data.
Wednesday, June 09, 2004
Visio to anything
Couple of weeks back i got myself actively involved with the design team and realized that most of the time was spent in getting the class diagrams from Visio (modelling tool) and stored procedures documented as per the custom design document template.
Technologies
- Visio,
- .NET Office Extensibility Add-in,
- MS Word,
- VBA,
- XMI,
- XSL,
- CSS
Approach:
Visio does provide a reporting add-in but unfortunately it is neither readable nor is it customizable and so started the thought to work on an alternative.
Microsoft always has a means to automate/customize/extend their products and so do they have UML to XMI Export Functionality, meaning a Visio UML Model can be exported to XML Metadata Interchange (XMI) format. This is build using .NET Office extensibility Add-in.
Now the XMI that is generated by Visio uses UML.dtd, which unfortunately is not distributed by Microsoft but have provided the resource in the readme.txt. With XMI & DTD in place i am sure of a valid Visio XMI file.
The next step was to display the XMI data in a custom format and the best alternative was to use eXtensible Stylesheet Language (XSL), now I needed to understand the structure of Visio XMI file and this is a tough job because there is no documentation available whatsoever to understand how visio model is interpretted in XMI format.
Attached a CSS to XSL to apply the formatting styles including header styles.
The next step was to place this information at an appropriate postion with in the design document template, hence created a .dot file, which is a template file for word.
Created a macro in word VBA that will use MSXML 2.0/4.0 and dynamically translate XMI with XSL and insert it into appropriate position.
Rebuild the table of contents, which will now include the design headings as defined by the CSS.
Please do drop me a comment if you need the UML to XMI add-in/DTD/XSL/CSS/DOT.
Custom Datagrid
This datagrid custom webcontrol will provide out of the box functionalities for the following features:
- CAT Stylesheet for HeadingItemStyle, EditItemStyle, SelectedItemStyle
- Inline of Page Redirect on Edit
- Captions for Edit, Update, Cancel & Delete buttons can be either text or graphic
- On double click of any row, editcommand, pageredirect of the row will be performed
- On single click of any row, selectcommand will be performed on the client end, thus saving the roundtrip to server.
- Sorting of the columns ASC/DESC on corresponding clicks on the column header with glmph
- Paging of the datagrid
- Maintaining State Across Pages For Checked Records
- Complement Inline Edit & Delete Support
- Fully Editable Support
- Maintains Concurrency Checks For InlineEdit Records
- Makes A Particular Row or Column ReadOnly
/// <summary>
/// File Name: EMSDataGrid.cs
/// Description:
///<Author> Amith Ellur & Yasin Mukadam</Author>
///<Date> 11-Feb-2004</Date>
///<Description>This datagrid custom webcontrol will provide out of the box functionalities for the following:
///1.   CAT Stylesheet for HeadingItemStyle, EditItemStyle, SelectedItemStyle
///2.   Inline of Page Redirect on Edita
///3.   Captions for Edit, Update, Cancel & Delete buttons can be either text or graphic
///4.   On double click of any row, editcommand, pageredirect of the row will be performed
///5.   On single click of any row, selectcommand will be performed on the client end,
///thus saving the roundtrip to server.
///6.  Sorting of the columns ASC/DESC on corresponding clicks on the column header
///7.  Paging of the datagrid
///8.  Maintaining State Across Pages For Checked Records
///9.  Complement Inline Edit & Delete Support
///10. Fully Editable Support
///11. Maintains Concurrency Checks For InlineEdit Records
///12. Makes A Particular Row or Column ReadOnly
///</Description>
/// </summary>
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Collections;
using System.Text;
using System.IO;
using Caterpillar.Ems;
using System.Text.RegularExpressions;
using System.Web.Handlers;
using System.Globalization;
using System.Web;
namespace Caterpillar.Ems.Controls
{
/// Summary description for EMSDataGrid.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:EMSDataGrid runat=server></{0}:EMSDataGrid>")]
public class EMSDataGrid : System.Web.UI.WebControls.DataGrid
{
/// <summary>
///  Used To Set The Default Validator Control Style Sheet
/// </summary>
const string VALIDATORSTYLESHEET = "RequiredFieldValidator"
/// <summary>
/// Used To Set The Default Range Validator Control Error Message
/// </summary>
const string RANGEERRORMESSAGE = "<BR><BLINK>||Invalid Data||</BLINK>"
/// <summary>
/// Used To Set The Default Required Validator Control Error Message
/// </summary>
const string REQUIREDERRORMESSAGE = "<BR><BLINK>||Required||</BLINK>"
/// <summary>
/// Used To Set The Default Regular Validator Control Error Message
/// </summary>
const string REGULARERRORMESSAGE = "<BR><BLINK>||Invalid Format||</BLINK>"
/// <summary>
/// Used To Set The Default Custom Validator Control Error Message
/// </summary>
const string CUSTOMERRORMESSAGE = "<BR><BLINK>||Custom Validation Failed||</BLINK>"
/// <summary>
///  Used To Set The Default DropDown Text
/// </summary>
const string DROPDOWNDEFAULTTEXT = "||-SELECT-||"
/// <summary>
/// Used To Set The DropDownStyle Attribute
/// </summary>
const string DROPDOWNSTYLE = "DropDownStyle"
/// <summary>
/// Name Of The Hidden CheckboxState Control
/// </summary>
const string HIDDENCHECKSTATE = "hiddencheckstate"
/// <summary>
/// Name Of The Hidden Control For Storing The NoOfRecordsChecked
/// </summary>
const string HIDDENNORECORDSCHECKBOXSTATE = "hiddennoofrecordscheckboxstate"
/// <summary>
/// Name Of The Hidden Control For Storing The Total Number Of Records
/// </summary>
const string HIDDENCHECKBOXSTATECOUNT = "hiddencheckboxstatecount"
/// <summary>
/// Name Of The hidden Control To Store CheckBox State
/// </summary>
const string HIDDENCONCURRENCYSTATE = "hiddenconcurrencystate"
/// <summary>
/// Name Of The HiddenControlWhich Stores The PreviousPage
/// </summary>
const string HIDDENPREVIOUSPAGE = "hiddenpreviouspage"
/// <summary>
/// Name Of The ReadOnly TextBoxStyle
/// </summary>
const string READONLYTEXTBOXSTYLE = "ReadOnlyTextBoxStyle"
/// <summary>
/// Name Of The TextBoxStyle
/// </summary>
const string TEXTBOXSTYLE = "TextBoxStyle"
/// <summary>
/// Name Of The hidden Control Used For Validating The Selected Record Id
/// </summary>
const string HIDDENCONCURRENCYIDCONCTROL = "hiddenconcurrencyidcontrol"
#endregion
#region Member Variables
/// <summary>
/// Defined enumerations for the different types of edit, delete, caption and stylesheet use
/// </summary>
public enum EditType { UnAuthorized = 0, InLine = 1, PageRedirect = 2 };
/// <summary>
/// Defined enumeration for the different type of delete message
/// </summary>
public enum DeleteType { DeleteWithConfirmation = 0, DeleteWithOutConfirmation = 1 };
/// <summary>
/// Defined enumeration for the different type of caption Type
/// </summary>
public enum CaptionType { Text = 0, Graphics = 1 };
/// <summary>
/// Used To Specify The Default Style Sheet
/// </summary>
public enum StyleSheetType { None = 0, CAT = 1, Default = 2 };
/// <summary>
/// Used To Specify The Status Of The Edit Button
/// </summary>
private bool editVisible;
/// <summary>
/// Used To Specify The Status Of The Delete Button
/// </summary>
private DeleteType allowDelete;
/// <summary>
/// Used To Specify The Status Of The Delete Button
/// </summary>
private bool deleteVisible;
/// <summary>
/// Used To Specify The Control Caption
/// </summary>
private CaptionType controlCaption;
/// <summary>
/// Used To Specifiy The Style Sheet Type
/// </summary>
private StyleSheetType styleSheet;
/// <summary>
/// Used To Specify The Status Of Edit On Double Click
/// </summary>
private bool editOnDoubleClick;
/// <summary>
/// Used To Specify The Status Of The Edit On single Click
/// </summary>
private bool selectOnSingleClick;
/// <summary>
/// Used To Specify The Id Of The Currently Selected Record On The Client Side
/// </summary>
private string keyHiddenControlId;
/// <summary>
/// Used To Specify The Status Of Fully Editable Grid
/// </summary>
private bool blnFullEdidtable;
/// <summary>
/// Used To Specify The Status Of The Inline Edit Enhance Features
/// </summary>
private bool blnEnhanceEdit;
/// <summary>
/// Stores The DataMembers Extended Properties For Each DataColumn
/// </summary>
private System.Data.PropertyCollection PropertyCollection;
/// <summary>
/// Stores The Max Decimal Value
/// </summary>
private string DecimalMaxValue = System.Configuration.ConfigurationSettings.AppSettings["DecimalMaxValue"];
/// <summary>
/// Stores The Min Decimal Value
/// </summary>
private string DecimalMinValue = System.Configuration.ConfigurationSettings.AppSettings["DecimalMinValue"];
/// <summary>
/// DataTable Which Contains The Modified Data Of The DataGrid After An Post Back From Inline Edit Or Fully Editable grid
/// </summary>
private DataTable dtModifiedDataTable = new DataTable();
/// <summary>
/// Maintains The Status Of The CheckBox State
/// </summary>
private bool blnCheckBoxState;
/// <summary>
/// Column Number From The DataMember On Which To Maintain The CheckBox State
/// </summary>
private int intCheckBoxColumn;
/// <summary>
/// Hidden Control Name Of The CheckBoxState Property
/// </summary>
private string strHiddenCheckBoxState;
/// <summary>
/// Hidden Control Name Of The CheckBoxState Property
/// </summary>
private string strNoOfRecordsCheckBoxState;
/// <summary>
/// Hidden Control Name Of The CheckBoxState Property
/// </summary>
private string strCheckBoxStateCount;
/// <summary>
/// Hidden Control Name Of The Previously Selected Page
/// </summary>
private string strHiddenPreviousPage;
/// <summary>
/// Number Of Records Selected For The Current Page
/// </summary>
private int intNoOfRecordsCheckBoxState = 0;
/// <summary>
/// DataSet Which Contains The CheckBox Ids For All The Pages
/// </summary>
private DataSet dsCheckBoxState;
/// <summary>
/// Stores The Name Of The Hidden Control Of Header Column
/// </summary>
private string strHeaderCheckBoxId = string.Empty;
/// <summary>
/// Hidden Control Which Stores The Id Of The Currently Selected Row On The Client Side
/// </summary>
private HtmlInputHidden hidConcurrencyIdControl = new HtmlInputHidden();
/// <summary>
/// Hidden Control Which Stores The Id Of The Currently Selected Row On The Client Side
/// </summary>
private string strConcurrencyIdControl;
/// <summary>
///
/// </summary>
private bool blnClearGridStatus = false;
#endregion
#region Events
/// <summary>
/// define the events for EMS DataGrid. This will be listed under EMS Events
/// </summary>
[Category("EMS Events"), Description("Fires when edit is clicked.")]
public event DataGridCommandEventHandler EditPage;
/// <summary>
///
/// </summary>
public event EMSExceptionEventHandler EMSDataGridRaiseException;
#endregion
#region Properties
/// <summary>
/// Attribute of the control to contain AllowEdit.
/// This will say if we need to provide edit functionality
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify if edit option is to be made available.")]
public EditType AllowEdit
{
{
{
else
{
set
{
{
/// <summary>
/// Attribute of the control to contain KeyHiddenControlId.
/// This will contain the id of the field to which the datagrid is associated for different functions
/// This will be the id of the associated control
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify the field in which the primary key value has to be displayed.")]
public string KeyHiddenControlId
{
{
set
{
/// <summary>
/// Attribute of the control to contain AllowDelete.
/// This will say if we need to provide delete functionality
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify if delete option is to be made available.")]
public DeleteType AllowDelete
{
{
set
{
/// <summary>
/// Attribute of the control to contain controlCaption.
/// This will say what kind of caption is used
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify the caption style for the edit and delete columns.")]
public CaptionType ControlCaption
{
{
set
{
/// <summary>
/// Attribute of the control to contain StyleSheet.
/// This will say what kind of StyleSheet is used
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify the style sheet to be used to render the rows.")]
public StyleSheetType StyleSheet
{
{
set
{
/// <summary>
/// Attribute of the control to contain EditOnDoubleClick.
/// This will say if we need to provide edit functionality on row double click as well
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify if edit to be made available on double clicking the row.")]
public bool EditOnDoubleClick
{
{
set
{
/// <summary>
/// Attribute of the control to contain SelectOnSingleClick.
/// This will say if we need to provide select functionality on row single click as well
/// </summary>
[Category("EMS Properties"),
DefaultValue(""), Description("Specify if the row has to be selected on single click.")]
public bool SelectOnSingleClick
{
{
set
{
/// <summary>
/// Attribute of the control to contain EditVisible.
/// This will say if edit link on the grid will be displayed or not
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify if the edit column is to be displayed.")]
public bool EditVisible
{
{
set
{
/// <summary>
/// Attribute of the control to contain EditVisible.
/// This will say if delete link on the grid will be displayed or not
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify if the delete column is to be displayed.")]
public bool DeleteVisible
{
{
set
{
/// <summary>
/// Specify if the Grid Will Be Fully Editable
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify if the Grid Will Be Fully Editable.")]
public bool FullEditable
{
{
set
{
/// <summary>
/// Specify if the Grid Will Be Contain Enhance Features For Enline Edit.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specify if the Grid Will Be Contain Enhance Features For Enline Edit.")]
public bool EnhanceEdit
{
{
set
{
/// <summary>
/// Returns The Updated DataSet Of The Grid i.e. When The Update Event Is Fired.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Returns The Updated DataSet Of The Grid i.e. When The Update Event Is Fired.")]
public DataSet ModifiedDataSet
{
{
{
this.dtModifiedDataTable.TableName = ((DataView)this.DataSource).Table.TableName;
//((DataView)this.DataSource).DataSetName
DataSet ds = new DataSet();
ds.Tables.Add(this.dtModifiedDataTable);
this.EditItemIndex = -1;
return ds;
/// <summary>
/// Speficies If The CheckBox State Is Going To Be Maintained Accross Pages.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Speficies If The CheckBox State Is Going To Be Maintained Accross Pages.")]
public bool CheckBoxState
{
{
set
{
/// <summary>
/// Column Number Of The DataSource Of Which To Maintain State.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Column Number Of The DataSource Of Which To Maintain State.")]
public int CheckBoxColumn
{
{
set
{
/// <summary>
/// Returns The DataSet For Checked Columns Accross Pages.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Returns The DataSet For Checked Columns Accross Pages.")]
public DataSet ReadCheckBoxStateData
{
{
if (this.blnCheckBoxState)
{
this.WriteHiddenControl();
//Validating If The DataSet Exists
if (!object.Equals(this.dsCheckBoxState, null))
{
if (!object.Equals(this.dsCheckBoxState.Tables[this.DataMember.ToString()], null))
{
if (this.dsCheckBoxState.Tables[this.DataMember.ToString()].Rows.Count == 0)
{
return null;
else
{
//this.ClearCheckBoxState();
//Returning The Newly Populated DataSet
return this.dsCheckBoxState;
else
{
return null;
else
{
return null;
else
{
return null;
/// <summary>
/// Returns The Hidden Control Id Which Contain The No Of Records Checked For Current Page.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Returns The Hidden Control Id Which Contain The No Of Records Checked For Current Page.")]
public string NoOfRecordsCheckBoxState
{
{
/// <summary>
/// Returns The Hidden Control Id Which Contain The No Of Records Checked For All The Pages.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Returns The Hidden Control Id Which Contain The No Of Records Checked For All The Pages.")]
public string CheckBoxStateCount
{
{
/// <summary>
/// Returns The Hidden Control Id Which Contain The checkBox State.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Returns The Hidden Control Id Which Contain The checkBox State.")]
public string HiddenCheckBoxState
{
{
/// <summary>
/// Specifies To Clear The DataSet From The ViewState.
/// </summary>
[Category("EMS Properties"), DefaultValue(""), Description("Specifies To Clear The DataSet From The ViewState.")]
public void ClearCheckBoxState()
{
if (!object.Equals(this.ViewState[this.strHiddenCheckBoxState], null))
{
//
this.blnClearGridStatus = true;
#endregion
#region OverReidden Events And Method Of The DataGrid
#region Events That Get Fired Each Time The DataGrid Is Processed
/// <summary>
/// calling the EMS Datagrid Constructor
/// </summary>
public EMSDataGrid()
{
this.ShowHeader = true;
this.AutoGenerateColumns = false;
//this.AllowSorting = true;
this.BorderColor = Color.Black;
this.BorderStyle = BorderStyle.Solid;
// Set the Handlers for the events to be handled in EMS Datagrid
CancelCommand += new DataGridCommandEventHandler(EMSDataGrid_CancelCommand);
EditCommand += new DataGridCommandEventHandler(EMSDataGrid_EditCommand);
UpdateCommand += new DataGridCommandEventHandler(EMSDataGrid_UpdateCommand);
SortCommand += new DataGridSortCommandEventHandler(EMSDataGrid_SortCommand);
DataBinding += new EventHandler(EMSDataGrid_DataBinding);
PageIndexChanged += new DataGridPageChangedEventHandler(EMSDataGrid_PageIndexChanged);
/// <summary>
/// Get Fired When The Instance If The Grid Is Fired
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
this.Columns.Clear();
if (this.AllowPaging || this.AllowCustomPaging)
{
this.PagerStyle.Mode = PagerMode.NumericPages;
this.PagerStyle.HorizontalAlign = HorizontalAlign.Left;
this.PageSize = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["RowsPerPage"].ToString());
if (object.Equals(this.NamingContainer.ClientID, null))
{
else
{
//Validating If The CheckBoxState Has To Be Maintained
if (this.blnCheckBoxState)
{
if (object.Equals(this.NamingContainer.ClientID, null))
{
this.strNoOfRecordsCheckBoxState = this.ClientID + ":" + HIDDENNORECORDSCHECKBOXSTATE;
this.strCheckBoxStateCount = this.ClientID + ":" + HIDDENCHECKBOXSTATECOUNT;
this.strHiddenPreviousPage = this.ClientID + ":" + HIDDENPREVIOUSPAGE;
else
{
this.strNoOfRecordsCheckBoxState = this.NamingContainer.ClientID + ":" + this.ID + ":" + HIDDENNORECORDSCHECKBOXSTATE;
this.strCheckBoxStateCount = this.NamingContainer.ClientID + ":" + this.ID + ":" + HIDDENCHECKBOXSTATECOUNT;
this.strHiddenPreviousPage = this.NamingContainer.ClientID + ":" + this.ID + ":" + HIDDENPREVIOUSPAGE;
//
//if(!object.Equals(HttpContext.Current.Session["DataSource"], null) && !object.Equals(HttpContext.Current.Session["DataMember"], null))
//{
//this.DataSource = HttpContext.Current.Session["DataSource"];
//this.DataMember = HttpContext.Current.Session["DataMember"].ToString();
//this.DataBind();
//}
/// <summary>
/// Method to handle the DataBinding event of the EMS Datagrid
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void EMSDataGrid_DataBinding(object sender, EventArgs e)
{
this.Columns.Clear();
//                                    
if (!this.IsTrackingViewState)
{
//if the page is loading for the first time, set the sort order to desc
if (this.ViewState["SortDirection"] == null)
{
this.ViewState["SortExpression"] = string.Empty;
//set the datasource
if (this.DataSource != null && this.DataSource is DataSet)
{
this.DataSource = ((DataSet)this.DataSource).Tables[this.DataMember.ToString()].DefaultView;
//
if (!(this.CurrentPageIndex <= (((DataView)this.DataSource).Table.Rows.Count / this.PageSize)))
{
//else
//{
//            this.CurrentPageIndex = 0;
//}
#region Set the Stylesheet styles
//Set the Stylesheet styles
//CAT
if (this.StyleSheet == StyleSheetType.CAT)
{
this.HeaderStyle.CssClass = "CATDataGridHeaderStyle"
this.ItemStyle.CssClass = "CATDataGridItemStyle"
this.AlternatingItemStyle.CssClass = "CATDataGridAlternatingStyle"
this.SelectedItemStyle.CssClass = "CATDataGridSelectedItemStyle"
this.FooterStyle.CssClass = "CATDataGridFooterStyle"
//Default
else if (this.StyleSheet == StyleSheetType.Default)
{
this.ItemStyle.CssClass = "DefaultDataGridItemStyle"
this.AlternatingItemStyle.CssClass = "DefaultDataGridAlternatingStyle"
this.HeaderStyle.CssClass = "DefaultDataGridHeaderStyle"
this.SelectedItemStyle.CssClass = "DefaultDataGridSelectedItemStyle"
#endregion
#region Adding Edit Item Template Column
//if the edit link is visible and edit on double click is enabled
//add the edit column
if (this.EditVisible || this.EditOnDoubleClick)
{
editCommandColumn.ButtonType = ButtonColumnType.LinkButton;
if (this.ControlCaption == CaptionType.Text)
{
editCommandColumn.UpdateText = "Apply"
editCommandColumn.CancelText = "Cancel"
else
{
editCommandColumn.ItemStyle.Font.Name = "wingdings 2"
editCommandColumn.EditText = "/"
editCommandColumn.UpdateText = "R"
editCommandColumn.CancelText = "T"
this.Columns.Add(editCommandColumn);
this.Columns[this.Columns.Count - 1].Visible = this.EditVisible;
#endregion
#region Adding Delete Item Template Column
//add the delete column
ButtonColumn deleteColumn = new ButtonColumn();
deleteColumn.CommandName = "delete"
if (this.ControlCaption == CaptionType.Text)
{
else
{
deleteColumn.ItemStyle.Font.Name = "webdings"
deleteColumn.Text = "r"
this.Columns.Add(deleteColumn);
this.Columns[this.Columns.Count - 1].Visible = this.DeleteVisible;
#endregion
//if the data source is not null, add the template column to each column
if (this.DataSource != null)
{
//HttpContext.Current.Session["DataSource"] = this.DataSource;
//HttpContext.Current.Session["DataMember"] = this.DataMember;
#region Adding ClientSide Script For SelectOnsingleClick etc...
string scriptString;
#region if the select on single click is true Set the OnClick Event of the grid
//if the select on single click is true Set the OnClick Event of the grid
if (this.SelectOnSingleClick)
{
scriptString = "<Script>"
scriptString += "var " + this.UniqueID.Replace(":", "_") + "SelectedItemIndex;"
scriptString += "var " + this.UniqueID.Replace(":", "_") + "SelectedItemStyle;"
if (this.DataSource != null && ((System.Data.DataView)this.DataSource).Table.Rows.Count > 0)
{
//                            //Code commented due to a bug, the bug still exists
if (this.KeyHiddenControlId != null && ((System.Web.UI.HtmlControls.HtmlInputHidden)this.Page.FindControl(this.KeyHiddenControlId)) != null)
{
if (this.AllowPaging && this.PagerStyle.Position == PagerPosition.TopAndBottom)
{
else
{
//this.Page.RegisterStartupScript(this.UniqueID.Replace(":","_") + "ScrolltoElement","<Script> document.getElementById(" + this.UniqueID.Replace(":","_") + "SelectedItemIndex).scrollIntoView(false); </Script>");
else
scriptString += " {"
scriptString += " try {"
scriptString += " if (" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex != event.srcElement.parentElement.id && event.srcElement.parentElement.id!='')"
scriptString += " {"
//if(this.FullEditable) scriptString += "alert(" + this.UniqueID.Replace(":","_") + "SelectedItemIndex);"
//                      scriptString += "//Set Previously Selected Row to Alternating Style"
scriptString += " if (" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex != '1')"
scriptString += " document.getElementById(" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex).className=" + this.UniqueID.Replace(":", "_") + "SelectedItemStyle;"
//                      scriptString += "//Set Currently Selected Row to Selected Style"
scriptString += " " + this.UniqueID.Replace(":", "_") + "SelectedItemIndex = event.srcElement.parentElement.id;"
if (this.KeyHiddenControlId != null)
if (this.StyleSheet == StyleSheetType.CAT)
//enhanced for druv to allow checkbox click selection of row
scriptString += " if (" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex != event.srcElement.parentElement.parentElement.id && event.srcElement.parentElement.parentElement.id!='')"
scriptString += " {"
//                      scriptString += "//Set Previously Selected Row to Alternating Style"
scriptString += " if (" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex != '1')"
scriptString += " document.getElementById(" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex).className=" + this.UniqueID.Replace(":", "_") + "SelectedItemStyle;"
//                      scriptString += "//Set Currently Selected Row to Selected Style"
scriptString += " " + this.UniqueID.Replace(":", "_") + "SelectedItemIndex = event.srcElement.parentElement.parentElement.id;"
if (this.KeyHiddenControlId != null)
//                                                                                                                                                
if (this.StyleSheet == StyleSheetType.CAT)
scriptString += "}"
scriptString += "catch (e) {}"
scriptString += "}"
scriptString += " </Script>"
//register the script
this.Page.RegisterClientScriptBlock(this.UniqueID.Replace(":", "_") + "SelectMe", scriptString);
#endregion
#region if the edit on double click is true, Set the doubleClick Event of the grid
//if the edit on double click is true, Set the doubleClick Event of the grid
if (this.EditOnDoubleClick && this.AllowEdit == EditType.UnAuthorized)
{
scriptString = "<Script>"
scriptString += " function " + this.UniqueID.Replace(":", "_") + "OpenMe()"
scriptString += " {"
scriptString += " }"
scriptString += " </Script>"
this.Page.RegisterClientScriptBlock(this.UniqueID.Replace(":", "_") + "OpenMe", scriptString);
if (this.EditOnDoubleClick && this.AllowEdit != EditType.UnAuthorized)
{
scriptString = "<Script>"
if (!this.SelectOnSingleClick)
scriptString += " {"
if (!this.SelectOnSingleClick)
scriptString += " var callEdit=new Function(document.getElementById(" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex).onedit);"
scriptString += " callEdit();"
scriptString += " }}"
scriptString += " </Script>"
this.Page.RegisterClientScriptBlock(this.UniqueID.Replace(":", "_") + "OpenMe", scriptString);
#endregion
#region Call Delete Event of the Selected Item
//Call Delete Event of the Selected Item
scriptString = "<Script>"
scriptString += " function " + this.UniqueID.Replace(":", "_") + "DeleteMe()"
scriptString += " {"
scriptString += " var status=confirm('" + Resource.Application.DeleteConfirmationMessage + "');"
scriptString += " if (!status) return;"
scriptString += " if (" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex != '1'){ "
scriptString += " var callDelete=new Function(document.getElementById(" + this.UniqueID.Replace(":", "_") + "SelectedItemIndex).onDelete);"
scriptString += " callDelete();"
scriptString += " } }"
scriptString += " </Script>"
this.Page.RegisterClientScriptBlock(this.UniqueID.Replace(":", "_") + "DeleteMe", scriptString);
#endregion
#endregion
//this.DataBind();
if (this.ViewState["SortExpression"].ToString().Length != 0)
/// <summary>
/// Gets Fired Each Time The DataGrid Is Processded
/// </summary>
/// <param name="e"></param>
protected override void OnItemCreated(DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Pager)
{
TableCell pager = (TableCell)e.Item.Controls[0];
pager.HorizontalAlign = HorizontalAlign.Left;
//Add Cell to Row to Hold Row Count Label
//                                                                TableCell newcell = new TableCell();
//                                                                newcell.HorizontalAlign = HorizontalAlign.Right;
//Add Label Indicating Row Count
Label lblNumRecords = new Label();
lblNumRecords.CssClass = "LabelStyle"
lblNumRecords.ID = "lblNumRecords"
pager.Controls.Add(lblNumRecords);
Table pagerTable = new Table();
pagerTable.Width = Unit.Percentage(100);
pagerTable.Rows.Add(new TableRow());
pagerTable.Rows[0].CssClass = e.Item.CssClass;
pagerTable.Rows[0].Cells.Add(pager);
//                                                                pagerTable.Rows[0].Cells.Add(newcell);
e.Item.Controls.Add(new TableCell());
((TableCell)e.Item.Controls[0]).ColumnSpan = pager.ColumnSpan;
e.Item.Controls[0].Controls.Add(pagerTable);
try
{
{
catch
{
}
/// <summary>
/// Method to handle the ItemDataBound event of the EMS Datagrid
/// </summary>
/// <param name="e"></param>
protected override void OnItemDataBound(DataGridItemEventArgs e)
{
//Set the Sort Glyph
if (e.Item.ItemType == ListItemType.Header && this.ViewState["SortExpression"] != null)
{
if (this.ViewState["SortExpression"].ToString().Length != 0)
{
{
{
lblSorted.Font.Name = "webdings"
lblSorted.Font.Size = FontUnit.XSmall;
if (this.ViewState["SortDirection"].ToString() == " ASC")
//only for items and alternating items
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (((DataRowView)e.Item.DataItem).DataView.Table.PrimaryKey.Length != 0)
e.Item.Attributes.Add("onclick", this.UniqueID.Replace(":", "_") + "SelectMe(); document.forms[0].item(\"" + this.strConcurrencyIdControl + "\").value='" + e.Item.Attributes["ID"] + "';");
{
//Set the tooltip if the captionstyle is graphics
if (this.ControlCaption == CaptionType.Graphics)
if (this.EditOnDoubleClick)
{
//this is to pass the selected item id as an argument to the event.
editbutton.CommandArgument = e.Item.Attributes["ID"];
e.Item.Attributes.Add("onedit", Page.GetPostBackClientHyperlink(editbutton, e.Item.Attributes["ID"]) + " document.forms[0].item(\"" + this.strConcurrencyIdControl + "\").value='" + e.Item.Attributes["ID"] + "';");
//                
if (this.DeleteVisible && this.AllowDelete == DeleteType.DeleteWithConfirmation && e.Item.Cells[1].Controls.Count > 0)
{
//
if (e.Item.Cells[1].Controls[0] is LinkButton)
{
else if (e.Item.Cells[0].Controls[0] is LinkButton)
{
//                                                                                                                                                                
if (!object.Equals(deletebutton, null))
{
if (this.ControlCaption == CaptionType.Graphics)
if (this.AllowDelete == DeleteType.DeleteWithConfirmation)
{
deletebutton.CommandArgument = e.Item.Attributes["ID"];
e.Item.Attributes.Add("onDelete", Page.GetPostBackClientHyperlink(deletebutton, e.Item.Attributes["ID"]) + " document.forms[0].item(\"" + this.strConcurrencyIdControl + "\").value='" + e.Item.Attributes["ID"] + "';");
try
{
if (this.editOnDoubleClick)
{
else
{
//this is to pass the selected item id as an argument to the event.
deletebutton.CommandArgument = e.Item.Attributes["ID"];
e.Item.Attributes.Add("onDelete", Page.GetPostBackClientHyperlink(deletebutton, e.Item.Attributes["ID"]) + " document.forms[0].item(\"" + this.strConcurrencyIdControl + "\").value='" + e.Item.Attributes["ID"] + "';");
catch
{
#endregion
#region From This Part Implements EMS 2.0 Written Yasin
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
{
{
DataTable dt = ((DataView)this.DataSource).Table;
//this.BindServerControl(e.Item, 0, e.Item.ItemIndex, dt.Rows[e.Item.ItemIndex], dt.Columns, dt.Columns.Count);
this.SetDropDownSelectedValue(e, 1);
//
this.SetRowColumnReadOnly(e.Item, 1, e.Item.ItemIndex, dt.Rows[e.Item.ItemIndex], dt.Columns, dt.Columns.Count);
//
this.AddValidatorControl(e, 1);
//
this.AddMultipleControls(e, 1);
//
this.AddDateControl(e, 1);
//
this.FormatGridCell(e, 1);
else if (this.EnhanceEdit)
{
{
DataTable dt = ((DataView)this.DataSource).Table;
//
this.BindServerControl(e.Item, 2, e.Item.ItemIndex, dt.Rows[e.Item.ItemIndex], dt.Columns, dt.Columns.Count);
//
this.AddValidatorControl(e, 2);
//
this.AddMultipleControls(e, 2);
//
this.AddDateControl(e, 2);
//Removing The Delete Button Link Incase of Edit Mode
if (e.Item.Cells[1].Controls[0] is LinkButton)
{
else
{
{
if (e.Item.ItemIndex < dt.Rows.Count)
{
this.FormatGridCell(e, 2);
else
{
//Adding The Feature Of CheckBoxState
if (this.blnCheckBoxState)
{
#endregion
base.OnItemDataBound(e);
/// <summary>
/// Get Fired to Before The HTML Content Is Rendered
/// </summary>
/// <param name="e"></param>
protected override void OnPreRender(EventArgs e)
{
{
int endRecord = (startRecord + this.PageSize) - 1;
if (((DataView)this.DataSource).Count < endRecord)
//Set the top pager
((Label)this.Controls[0].Controls[0].FindControl("lblNumRecords")).Text = "&nbsp;&nbsp;&nbsp;Records " + startRecord.ToString() + " to " + endRecord.ToString() + " of " + totalRecord.ToString();
//Clear the bottom pager
((Label)this.Controls[0].Controls[this.Controls[0].Controls.Count - 1].FindControl("lblNumRecords")).Text = ""
//
if (((DataView)this.DataSource).Count == 0)
{
((Label)this.Controls[0].Controls[0].FindControl("lblNumRecords")).Text = "There are no records to be displayed."
this.Controls[0].Controls.Remove(this.Controls[0].Controls[1]);
this.Controls[0].Controls.Remove(this.Controls[0].Controls[2]);
this.Controls[0].Controls[0].Controls[0].Controls[0].Controls[0].Controls.Remove(this.Controls[0].Controls[0].Controls[0].Controls[0].Controls[0].Controls[0]);
this.BorderColor = Color.Transparent;
this.BorderStyle = BorderStyle.None;
//Adding The ClientSide Scripts For CheckBoxState
if (this.blnCheckBoxState)
{
//
if (this.Items.Count > 0)
{
this.hidConcurrencyIdControl.ID = HIDDENCONCURRENCYIDCONCTROL;
//
this.hidConcurrencyIdControl.Value = this.Items[0].Attributes["ID"];
//
this.Controls.Add(this.hidConcurrencyIdControl);
//Adding The Focus On The Editted Item Control
//                                    if(this.EnhanceEdit)
//                                    {
//                                                bool blnFocus = false;
//                                                for(int item = 0; item < this.Items.Count; item++)
//                                                {
//                                                            if(this.Items[item].ItemType == ListItemType.EditItem)
//                                                            {
//                                                                        for(int cell = 0; cell < this.Items[item].Cells.Count; cell++)            
//                                                                        {
//                                                                                    if(this.Items[item].Cells[cell].Visible)
//                                                                                    {
//                                                                                                for(int control = 0; control < this.Items[item].Cells[cell].Controls.Count; control++)
//                                                                                                {
//                                                                                                            if(this.Items[item].Cells[cell].Controls[control] is TextBox)
//                                                                                                            {
//                                                                                                                        if(!((TextBox)this.Items[item].Cells[cell].Controls[control]).ReadOnly)
//                                                                                                                        {
//                                                                                                                                    this.Page.RegisterClientScriptBlock("focus", "<script>document.forms[0].item(\"" + ((TextBox)this.Items[item].Cells[cell].Controls[control]).ClientID + "\").focus()</script>");
//                                                                                                                                    blnFocus = true;
//                                                                                                                                    break;
//                                                                                                                                                
//                                                                                                                        }
//                                                                                                            }
//                                                                                                            else if(this.Items[item].Cells[cell].Controls[control] is DropDownList)
//                                                                                                            {
//                                                                                                                        this.Page.RegisterClientScriptBlock("focus", "<script>document.forms[0].item(\"" + ((DropDownList)this.Items[item].Cells[cell].Controls[control]).ClientID + "\").focus()</script>");
//                                                                                                                        blnFocus = true;
//                                                                                                                        break;
//                                                                                                            }
//                                                                                                }
//                                                                                    }
//                                                                                    if(blnFocus) break;
//                                                                        }
//                                                            }
//                                                            if(blnFocus) break;
//                                                }
//                                    }                                    
base.OnPreRender(e);
/// <summary>
///
/// </summary>
/// <param name="savedState"></param>
//protected override void LoadViewState(object savedState)
//{
//this.DataSource = HttpContext.Current.Cache["temp"];
//this.DataMember = HttpContext.Current.Cache["temp1"].ToString();
//this.DataBind();
//TODO: Yasin, This is where the columns controls should be added - Amith Ellur
//}
//protected override object SaveViewState()
//{
//HttpContext.Current.Cache["temp"]  = this.DataSource;
//HttpContext.Current.Cache["temp1"] = this.DataMember;
//this.ViewState;
//        return null;
//}
#endregion
#region Events That Get Fired On Post Back When Edit, Delete, Sorting, Paging etc.. Get Fired
/// <summary>
/// Method to handle the PageIndexChanged event of the EMS Datagrid
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void EMSDataGrid_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
this.EditItemIndex = -1;
this.CurrentPageIndex = e.NewPageIndex;
this.DataBind();
/// <summary>
/// Method to handle the CancelCommand event of the EMS Datagrid
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void EMSDataGrid_CancelCommand(object source, DataGridCommandEventArgs e)
{
this.DataBind();
/// <summary>
/// Method to handle the EditCommand event of the EMS Datagrid
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void EMSDataGrid_EditCommand(object source, DataGridCommandEventArgs e)
{
{
this.ValidateConcurrencyControl(e.Item.Attributes["ID"]);
//if inline edit, hide the delete column
if (this.AllowEdit == EditType.InLine)
{
ToggleDeleteColumn(false);
this.DataBind();
//if not inline edit, then redirect to the selected page
else if (this.AllowEdit == EditType.PageRedirect)
{
catch (Exception exception)
{
/// <summary>
/// Method to handle the UpdateCommand event of the EMS Datagrid
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void EMSDataGrid_UpdateCommand(object source, DataGridCommandEventArgs e)
{
if (this.EnhanceEdit)
{
this.ReadDataGridData(e.Item.ItemIndex);
//Creating A DataTable From The Default DataView
DataTable dt = ((DataView)this.DataSource).Table;
//Declaring the PK
DataColumn[] prk = dt.PrimaryKey;
//Coping the DataRow
DataRow dr = dt.Rows[e.Item.ItemIndex];
//Iterating Through the Primary Keys To Set The New Guid Incase A New Record Is Added
for (int dclength = 0; dclength < prk.Length; dclength++)
{
if (object.Equals(dr[prk[dclength].Ordinal], DBNull.Value))
{
if (dt.Columns[prk[dclength].ColumnName].ReadOnly)
{
dt.Columns[prk[dclength].ColumnName].ReadOnly = false;
dr[prk[dclength].ColumnName] = Guid.NewGuid();
dt.Columns[prk[dclength].ColumnName].ReadOnly = true;
//Iterating Through the DataColums To Set The Default Values For The New Data Row
for (int dclength = 0; dclength < dt.Columns.Count; dclength++)
{
if (dt.Columns[dclength].ReadOnly)
{
if (object.Equals(dr[dclength], DBNull.Value))
{
dt.Columns[dclength].ReadOnly = false;
dr[dclength] = dt.Columns[dclength].DefaultValue;
dt.Columns[dclength].ReadOnly = true;
//Copying the Structure of the datatable
this.dtModifiedDataTable = dt.Clone();
//Adding A new Row
DataRow newdr = this.dtModifiedDataTable.NewRow();
//Iterating To The Columns of the datarow
for (int i = 0; i < dr.ItemArray.Length; i++)
{
newdr[i] = dr.ItemArray[i];
//Adding The New DataRow
this.dtModifiedDataTable.Rows.Add(newdr);
//base.OnUpdateCommand(e);
//show the delete column of the datagrid
ToggleDeleteColumn(true);
/// <summary>
/// Method to handle the SortCommand event of the EMS Datagrid
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void EMSDataGrid_SortCommand(object source, DataGridSortCommandEventArgs e)
{
//Change the sort direction for next use.
if (this.ViewState["SortDirection"].ToString() == " DESC")
// Sort property with the name of the field to sort by.
((DataView)this.DataSource).Sort = e.SortExpression + this.ViewState["SortDirection"];
// Rebind the data source and specify that it should be sorted
// by the field specified in the SortExpression property.
this.DataBind();
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnDeleteCommand(DataGridCommandEventArgs e)
{
{
if (this.Items.Count == 1)
this.ValidateConcurrencyControl(e.Item.Attributes["ID"]);
base.OnDeleteCommand(e);
catch (Exception exception)
{
this.ProcessException(exception);
/// <summary>
/// This Helper Function Rasies The EMSDataGridRaiseException Event
/// </summary>
/// <param name="exception"></param>
private void ProcessException(Exception exception)
{
if (!object.Equals(this.EMSDataGridRaiseException, null))
{
else
{
/// <summary>
/// Used For Page Redirect
/// </summary>
/// <param name="e"></param>
protected virtual void OnEditPage(DataGridCommandEventArgs e)
{
#endregion
#endregion
#region Helper Functions Used In Class
/// <summary>
/// Show/Hide the DELETE column when in edit mode. This handles the visibility of Delete column based on DeleteVisible property
/// </summary>
/// <param name="bViewState"></param>
private void ToggleDeleteColumn(bool bViewState)
{
/// <summary>
/// This Helper function Is Called In The Page Index Changed Event To Store The Checked Records In The Dataset From The Hidden Control
/// </summary>
/// <param name="?"></param>
/// <returns></returns>
private void WriteHiddenControl()
{
{
if (this.DataSource == null && this.DataSource is DataSet)
{
//
string strHidden = HttpContext.Current.Request[this.strHiddenCheckBoxState];
//Validating If The user has checked any records
if (strHidden.Length > 0)
{
if (object.Equals(this.ViewState[this.strHiddenCheckBoxState], null))
{
DataTable dtCheckBoxState = new DataTable(this.DataMember.ToString());
//Adding Columns To The DataTable
dtCheckBoxState.Columns.Add(new DataColumn("PageNumber", System.Type.GetType("System.Int64")));
dtCheckBoxState.Columns.Add(new DataColumn("Id", System.Type.GetType("System.Guid")));
//Splitting The Strings
string[] spliter = strHidden.Split(new char[1] { '~' });
string[] strId = spliter[1].Split(new char[1] { '^' });
//Adding The Newly Checked Records Into The DataTable
for (int i = 0; i < strId.Length; i++)
{
DataView dv = ((DataView)this.DataSource);
//
DataColumn[] dc = dv.Table.PrimaryKey;
//
if (dc.Length == 1)
{
DataRow[] DataRowSearch = dv.Table.Select(dc[0].ColumnName + "='" + strId[i] + "'");
//
if (DataRowSearch.Length == 1)
{
dtCheckBoxState.Rows.Add(drCheckBoxState);
drCheckBoxState["PageNumber"] = spliter[0];
drCheckBoxState["Id"] = strId[i];
else
{
//Creating the Instance Of The DataSet
this.dsCheckBoxState = new DataSet();
//Adding the DataTable To The DataSet
this.dsCheckBoxState.Tables.Add(dtCheckBoxState);
else
{
this.dsCheckBoxState = new DataSet();
//Creating The Instance of StringReader Class
StringReader sr = new StringReader(this.ViewState[this.strHiddenCheckBoxState].ToString());
//Loading The DataSet From StringReader Class
this.dsCheckBoxState.ReadXml(sr);
//Fetching The datatable from the dataset
DataTable dtCheckBoxState = this.dsCheckBoxState.Tables[this.DataMember.ToString()];
//Splitting The Strings
string[] spliter = strHidden.Split(new char[1] { '~' });
//Filtering The DataTable Based on DataRows
DataRow[] dr = dtCheckBoxState.Select("PageNumber" + "='" + strHidden[0] + "'");
//Removing The DataRows Which Were Affected From The DataTable.Select Method
for (int drCtr = 0; drCtr < dr.Length; drCtr++)
{
//                        
if (spliter.Length == 2)
{
string[] strId = spliter[1].Split(new char[1] { '^' });
//Checking The DataRow Length
if (dr.Length == 0)
{
for (int i = 0; i < strId.Length; i++)
{
DataView dv = ((DataView)this.DataSource);
//
DataColumn[] dc = dv.Table.PrimaryKey;
if (dc.Length == 1)
{
DataRow[] DataRowSearch = dv.Table.Select(dc[0].ColumnName + "='" + strId[i] + "'");
//
if (DataRowSearch.Length == 1)
{
dtCheckBoxState.Rows.Add(drCheckBoxState);
drCheckBoxState["PageNumber"] = spliter[0];
drCheckBoxState["Id"] = strId[i];
else
{
else
{
for (int i = 0; i < strId.Length; i++)
{
DataView dv = ((DataView)this.DataSource);
//
DataColumn[] dc = dv.Table.PrimaryKey;
if (dc.Length == 1)
{
DataRow[] DataRowSearch = dv.Table.Select(dc[0].ColumnName + "='" + strId[i] + "'");
//
if (DataRowSearch.Length == 1)
{
dtCheckBoxState.Rows.Add(drCheckBoxState);
drCheckBoxState["PageNumber"] = spliter[0];
drCheckBoxState["Id"] = strId[i];
else
{
//Storing The DataSet Into ViewState
//TODO: Amith Please Check This Option And Get Back
if (this.dsCheckBoxState.Tables[0].Rows.Count > 0)
{
this.intNoOfRecordsCheckBoxState = this.dsCheckBoxState.Tables[0].Rows.Count;
else
{
{
this.dsCheckBoxState = new DataSet();
//Creating The Instance of StringReader Class
StringReader sr = new StringReader(this.ViewState[this.strHiddenCheckBoxState].ToString());
//Loading The DataSet From StringReader Class
this.dsCheckBoxState.ReadXml(sr);
//Fetching The datatable from the dataset
DataTable dtCheckBoxState = this.dsCheckBoxState.Tables[this.DataMember.ToString()];
//Filtering The DataTable Based on DataRows
DataRow[] dr = dtCheckBoxState.Select("PageNumber" + "='" + HttpContext.Current.Request[this.strHiddenPreviousPage] + "'");
//Removing The DataRows Which Were Affected From The DataTable.Select Method
for (int drCtr = 0; drCtr < dr.Length; drCtr++)
{
//Storing The DataSet Into ViewState
//TODO: Amith Please Check This Option And Get Back
if (this.dsCheckBoxState.Tables[0].Rows.Count > 0)
{
else
{
//
if (!object.Equals(HttpContext.Current.Request[this.strCheckBoxStateCount], null))
{
if (HttpContext.Current.Request[this.strCheckBoxStateCount].Trim().Length > 0)
{
/// <summary>
/// Helper function Is used To Set The Various Item Template For The Grid
/// </summary>
private void SetColumnsCollection()
{
string strCellName;
int ctr;
//
if (this.EditOnDoubleClick && this.selectOnSingleClick)
{
else
{
//
foreach (DataColumn col in ((DataView)this.DataSource).Table.Columns)
{
this.PropertyCollection = col.ExtendedProperties;
TemplateColumn tc1 = new TemplateColumn();
if (this.intCheckBoxColumn == ctr)
{
else
{
tc1.ItemTemplate = new
if (!Object.Equals(col.ExtendedProperties[EMSDataGridExtendedProperties.Visibility], null))
{
this.Columns.Add(tc1);
//
ctr++;
/// <summary>
///  This Helper Function Is Used For Validating If The Selected Records Exists In Post Backs
/// </summary>
/// <param name="strID"></param>
private void ValidateConcurrencyControl(string strID)
{
{
{
/// <summary>
/// Helper Function Returns A DataTime Based On The Specific Format Used With Concurrency
/// </summary>
/// <param name="strDate"></param>
/// <returns></returns>
private DateTime DateConvertorConcurrency(string strDate)
{
return DateTime.ParseExact(strDate, "dd/MM/yyyy HH:mm:ss:fff", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None);
/// <summary>
/// Helper Function Returns A String Based On The Specific Format Used With Concurrency
/// </summary>
/// <param name="dtDate"></param>
/// <returns></returns>
private string DateConvertorConcurrency(DateTime dtDate)
{
/// <summary>
/// Helper function Is Used To Format The Date Based On System Preferences
/// </summary>
/// <param name="dtDate"></param>
/// <returns></returns>
public DateTime DateConvertor(string strDate)
{
return DateTime.ParseExact(strDate, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None);
/// <summary>
///  Helper function Is Used To Format The Date Based On System Preferences
/// </summary>
/// <param name="dtDate"></param>
/// <returns></returns>
public string DateConvertor(DateTime dtDate)
{
/// <summary>
/// Helper function converts A DataRow Value into Date
/// </summary>
/// <param name="objDate"></param>
/// <returns></returns>
private object GetValidDate(object objDate)
{
{
else
{
/// <summary>
/// Helper function converts A DataRow Value into Valid String Value
/// </summary>
/// <param name="strValue"></param>
/// <returns></returns>
private object GetValidValue(string strValue)
{
if (strValue.Length == 0)
{
else
{
/// <summary>
/// Helper function converts A String Value Into A DataRow Value
/// </summary>
/// <param name="strControlValue"></param>
/// <returns></returns>
private object SetValidDBValue(string strControlValue)
{
if (strControlValue.Length == 0)
{
else
{
/// <summary>
/// This helper function is called in the ItemDataBound Event to format the Item Cells based on the datatypes
/// </summary>
private void FormatGridCell(DataGridItemEventArgs e, int cells)
{
{
for (int i = 0; i < dt.Columns.Count; i++)
{
switch (dt.Columns[i].DataType.ToString())
{
break;
break;
goto case "Numeric"
goto case "Numeric"
goto case "Numeric"
goto case "Numeric"
goto case "Numeric"
goto case "Numeric"
e.Item.Cells[cells].HorizontalAlign = HorizontalAlign.Center;
//Format Based
for (int ctl = 0; ctl < e.Item.Cells[cells].Controls.Count; ctl++)
{
{
{
break;
else if (e.Item.Cells[cells].Controls[ctl] is TextBox)
{
{
break;
break;
break;
cells++;
catch
{
}
/// <summary>
/// Helper Functions Used to Various Validator Control
/// </summary>
/// <param name="e"></param>
/// <param name="cells"></param>
private void AddValidatorControl(DataGridItemEventArgs e, int cells)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
//Putting Required Field Validators For Colunms
if (!dt.Columns[i].ReadOnly && !dt.Columns[i].AllowDBNull)
{
{
{
e.Item.Cells[cells].Controls.Add(RequiredFieldValidatorControl(strCellName));
if (e.Item.Cells[cells].Controls[ctl] is DropDownList)
{
e.Item.Cells[cells].Controls.Add(RequiredFieldValidatorControl(strCellName));
//Putting The Range Validator To Handle Arthi OverFlow Error
switch (dt.Columns[i].DataType.ToString())
{
{
{
{
e.Item.Cells[cells].Controls.Add(this.RangeValidatorControl(strCellName, ValidationDataType.Double, dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.MaxValue], dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.MinValue]));
break;
//Adding Additional Required Field Validator Controls
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomRequiredFieldValidator], null))
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomRequiredFieldValidatorErrorMessage], null))
{
else
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomRequiredFieldValidatorCssClass], null))
{
else
{
for (int ctl = 0; ctl < e.Item.Cells[cells].Controls.Count; ctl++)
{
{
else if (e.Item.Cells[cells].Controls[ctl] is DropDownList)
{
rfv.ControlToValidate = strCellName;
e.Item.Cells[cells].Controls.Add(rfv);
//Adding Additional Regular Expression Validator Controls
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomRegularExpressionValidator], null))
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomRegularExpressionValidatorErrorMessage], null))
{
else
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomRegularExpressionValidatorCssClass], null))
{
else
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomRegularExpressionValidatorExpression], null))
{
else
{
for (int ctl = 0; ctl < e.Item.Cells[cells].Controls.Count; ctl++)
{
{
else if (e.Item.Cells[cells].Controls[ctl] is DropDownList)
{
rev.ControlToValidate = strCellName;
e.Item.Cells[cells].Controls.Add(rev);
//Adding Additional Custom Validator Controls
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomCustomValidator], null))
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomCustomValidatorErrorMessage], null))
{
else
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomCustomValidatorCssClass], null))
{
else
{
if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.CustomCustomValidatorClientValidationFunction], null))
{
else
{
for (int ctl = 0; ctl < e.Item.Cells[cells].Controls.Count; ctl++)
{
{
else if (e.Item.Cells[cells].Controls[ctl] is DropDownList)
{
cv.ControlToValidate = strCellName;
e.Item.Cells[cells].Controls.Add(cv);
//Range Validator
//Compare Validator
cells++;
/// <summary>
/// Helper Function Used To Add Multiple Controls
/// </summary>
/// <param name="e"></param>
/// <param name="cells"></param>
private void AddMultipleControls(DataGridItemEventArgs e, int cells)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
//Putting The Range Validator To Handle Arthi OverFlow Error
switch (dt.Columns[i].DataType.ToString())
{
{
for (int ctl = 0; ctl < e.Item.Cells[cells].Controls.Count; ctl++)
{
{
{
//Storing The Textbox Information In ElipseTextBox
textbox = ((TextBox)e.Item.Cells[cells].Controls[ctl]);
else if (e.Item.Cells[cells].Controls[ctl] is HtmlInputButton && !object.Equals(textbox, null))
{
else if (!object.Equals(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.MultipleControl], null))
{
object[] obj = (object[])dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.MultipleControl];
//
string strControlValue = string.Empty;
//
if (e.Item.Cells[cells].Controls[0] is TextBox)
{
else if (e.Item.Cells[cells].Controls[0] is Literal)
{
//
string[] spliter = strControlValue.Split(new char[1] { char.Parse(dt.Columns[i].ExtendedProperties[EMSDataGridExtendedProperties.MultipleControlDelimiter].ToString()) });
//
e.Item.Cells[cells].Controls.RemoveAt(0);
//
for (int ctr = 0; ctr < obj.Length; ctr++)
{
if (hashtable[EMSDataGridExtendedProperties.MultipleControlDropDown] is DropDownList)
{
if (this.FullEditable)
{
dropdownlist = new DropDownList();
else
{
dropdownlist.CssClass = DROPDOWNSTYLE;
if (object.Equals(dropdownlist.ID, null))
{
DataTable datatable = (DataTable)hashtable[EMSDataGridExtendedProperties.MultipleControlDropDownDataTable];
dropdownlist.DataSource = datatable;
dropdownlist.DataTextField = hashtable[EMSDataGridExtendedProperties.MultipleControlDropDownDataTextField].ToString();
dropdownlist.DataValueField = hashtable[EMSDataGridExtendedProperties.MultipleControlDropDownDataValueField].ToString();
dropdownlist.DataBind();
dropdownlist.Items[0].Text = DROPDOWNDEFAULTTEXT;
if (spliter.Length == obj.Length)
{
{
if (this.FullEditable)
{
{
{
if (!blnFlag)
{
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRequiredFieldValidator], null))
{
if (this.FullEditable)
{
else
{
rfv.ErrorMessage = REQUIREDERRORMESSAGE + "<BR>"
rfv.CssClass = VALIDATORSTYLESHEET;
rfv.ControlToValidate = dropdownlist.ID;
rfv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(rfv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlCompareValidator], null))
{
if (this.FullEditable)
{
else
{
cv.CssClass = VALIDATORSTYLESHEET;
cv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(cv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlCustomValidator], null))
{
if (this.FullEditable)
{
else
{
cv.CssClass = VALIDATORSTYLESHEET;
cv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(cv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRangeValidator], null))
{
if (this.FullEditable)
{
else
{
rv.CssClass = VALIDATORSTYLESHEET;
rv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(rv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRegularExpressionValidator], null))
{
if (this.FullEditable)
{
else
{
re.CssClass = VALIDATORSTYLESHEET;
re.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(re);
else
{
else
{
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRequiredFieldValidator], null))
{
if (this.FullEditable)
{
else
{
rfv.ErrorMessage = REQUIREDERRORMESSAGE + "<BR>"
rfv.CssClass = VALIDATORSTYLESHEET;
rfv.ControlToValidate = dropdownlist.ID;
rfv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(rfv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlCompareValidator], null))
{
if (this.FullEditable)
{
else
{
cv.CssClass = VALIDATORSTYLESHEET;
cv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(cv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlCustomValidator], null))
{
if (this.FullEditable)
{
else
{
cv.CssClass = VALIDATORSTYLESHEET;
cv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(cv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRangeValidator], null))
{
if (this.FullEditable)
{
else
{
//RangeValidator rv = (RangeValidator)hashtable[EMSDataGridExtendedProperties.MultipleControlRangeValidator];
rv.CssClass = VALIDATORSTYLESHEET;
rv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(rv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRegularExpressionValidator], null))
{
if (this.FullEditable)
{
else
{
re.CssClass = VALIDATORSTYLESHEET;
re.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(re);
else
{
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRequiredFieldValidator], null))
{
rfv.ErrorMessage = REQUIREDERRORMESSAGE + "<BR>"
rfv.CssClass = VALIDATORSTYLESHEET;
rfv.ControlToValidate = dropdownlist.ID;
rfv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(rfv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlCompareValidator], null))
{
cv.CssClass = VALIDATORSTYLESHEET;
cv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(cv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlCustomValidator], null))
{
cv.CssClass = VALIDATORSTYLESHEET;
cv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(cv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRangeValidator], null))
{
rv.CssClass = VALIDATORSTYLESHEET;
rv.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(rv);
if (!object.Equals(hashtable[EMSDataGridExtendedProperties.MultipleControlRegularExpressionValidator], null))
{
re.CssClass = VALIDATORSTYLESHEET;
re.Display = ValidatorDisplay.Dynamic;
e.Item.Cells[cells].Controls.Add(re);
break;
cells++;
/// <summary>
/// Helper Function Used To Set The Values For Editable Grid Items
/// </summary>
/// <param name="e"></param>
/// <param name="cells"></param>
/// <param name="row"></param>
/// <param name="dr"></param>
/// <param name="dc"></param>
/// <param name="columncount"></param>
private void BindServerControl(DataGridItem e, int cells, int row, DataRow dr, DataColumnCollection dc, int columncount)
{
DataTable dt = ((DataView)this.DataSource).Table;
//
DataColumn[] dcPrimaryKey;
//
dcPrimaryKey = dt.PrimaryKey;
#region Making The Whole Row As ReadOnly
if (dcPrimaryKey.Length == 1)
{
{
if (dr[dcPrimaryKey[0].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnlyRow].ToString()].GetType().ToString() == "System.Boolean")
{
if ((bool)dr[dcPrimaryKey[0].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnlyRow].ToString()])
{
if (!Object.Equals(dcPrimaryKey[0].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnlyStyle], null))
{
else
{
//
if (e.Cells[0].Controls[0] is LinkButton)
{
//
if (e.Cells[1].Controls[0] is LinkButton)
{
#endregion
//
for (int i = 0; i < columncount; i++)
{
{
//Putting The Range Validator To Handle Arthi OverFlow Error
switch (dc[i].DataType.ToString())
{
case ("System.Guid"):
{
{
if (e.Cells[cells].Controls[0] is Literal)
{
break;
else if (e.Cells[cells].Controls[ctl] is Literal)
{
break;
#region Setting TextBox Value with Decimal DataType
case ("System.Decimal"):
{
{
break;
break;
case ("System.Int16"):
case ("System.DateTime"):
{
{
{
{
this.ViewState["ItemIndex"] = e.ItemIndex;
else if (this.ViewState[HIDDENCONCURRENCYSTATE].ToString().Trim().Length > 0 && (int)this.ViewState["ItemIndex"] != e.ItemIndex)
{
{
this.ViewState["ItemIndex"] = e.ItemIndex;
break;
#endregion
#region Setting A Particular Column As ReadOnly In EnLine Edit
//
if (!object.Equals(dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly], null))
{
//
if (dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly].GetType().ToString() == "System.Boolean")
{
{
if (e.Cells[cells].Controls[ctl] is TextBox)
{
if ((bool)dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly])
{
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
//
if (e.Cells[cells].Controls[ctl] is DropDownList)
{
if ((bool)dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly])
{
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
//
else if (dr[dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly].ToString()].GetType().ToString() == "System.Boolean")
{
for (int ctl = 0; ctl < e.Cells[cells].Controls.Count; ctl++)
{
if (e.Cells[cells].Controls[ctl] is TextBox)
{
if ((bool)dr[dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly].ToString()])
{
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
//
if (e.Cells[cells].Controls[ctl] is DropDownList)
{
if ((bool)dr[dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly].ToString()])
{
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
#endregion
cells++;
/// <summary>
/// Helper function Used To Make A Row or Column ReadOnly
/// </summary>
/// <param name="e"></param>
/// <param name="cells"></param>
/// <param name="row"></param>
/// <param name="dr"></param>
/// <param name="dc"></param>
/// <param name="columncount"></param>
private void SetRowColumnReadOnly(DataGridItem e, int cells, int row, DataRow dr, DataColumnCollection dc, int columncount)
{
DataTable dt = ((DataView)this.DataSource).Table;
//
DataColumn[] dcPrimaryKey;
//
dcPrimaryKey = dt.PrimaryKey;
#region Making The Whole Row As ReadOnly
if (dcPrimaryKey.Length == 1)
{
{
if (dr[dcPrimaryKey[0].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnlyRow].ToString()].GetType().ToString() == "System.Boolean")
{
if ((bool)dr[dcPrimaryKey[0].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnlyRow].ToString()])
{
if (!Object.Equals(dcPrimaryKey[0].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnlyStyle], null))
{
else
{
//
foreach (TableCell tc in e.Cells)
{
{
{
Literal lit = new Literal();
lit.Text = ((TextBox)control).Text;
tc.Controls.Remove(control);
tc.Controls.Add(lit);
else if (control is DropDownList)
{
Literal lit = new Literal();
lit.Text = ((DropDownList)control).SelectedItem.Text;
tc.Controls.Remove(control);
tc.Controls.Add(lit);
else if (control is CheckBox)
{
#endregion
//
for (int i = 0; i < columncount; i++)
{
{
//
if (!object.Equals(dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly], null))
{
{
{
if (e.Cells[cells].Controls[ctl] is TextBox)
{
if ((bool)dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly])
{
//                                                                                                                                                                                                                                                                                                                                                                                                                                                        
lit.Text = ((TextBox)e.Cells[cells].Controls[ctl]).Text;
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
//
if (e.Cells[cells].Controls[ctl] is DropDownList)
{
if ((bool)dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly])
{
//
lit.Text = ((DropDownList)e.Cells[cells].Controls[ctl]).SelectedItem.Text;
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
//
if (e.Cells[cells].Controls[ctl] is CheckBox)
{
break;
//
else if (dr[dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly].ToString()].GetType().ToString() == "System.Boolean")
{
for (int ctl = 0; ctl < e.Cells[cells].Controls.Count; ctl++)
{
if (e.Cells[cells].Controls[ctl] is TextBox)
{
if ((bool)dr[dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly].ToString()])
{
//
lit.Text = ((TextBox)e.Cells[cells].Controls[ctl]).Text;
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
//
if (e.Cells[cells].Controls[ctl] is DropDownList)
{
if ((bool)dr[dc[i].ExtendedProperties[EMSDataGridExtendedProperties.ReadOnly].ToString()])
{
//
lit.Text = ((DropDownList)e.Cells[cells].Controls[ctl]).SelectedItem.Text;
e.Cells[cells].Controls.Add(lit);
e.Cells[cells].Controls.Remove(e.Cells[cells].Controls[ctl]);
break;
if (e.Cells[cells].Controls[ctl] is CheckBox)
{
break;
#endregion
cells++;
/// <summary>
/// Helper function Used To Set The Selected Value Of The Added DropDown Box
/// </summary>
/// <param name="e"></param>
/// <param name="cells"></param>
private void SetDropDownSelectedValue(DataGridItemEventArgs e, int cells)
{
string strLiteralText = null;
int intRemove = -1;
for (int i = 0; i < dt.Columns.Count; i++)
{
{
switch (dt.Columns[i].DataType.ToString())
{
{
{
intRemove = ctl;
if (e.Item.Cells[cells].Controls[ctl] is DropDownList)
{
{
if (intRemove > -1)
{
intRemove = -1;
break;
cells++;
/// <summary>
/// Helper Function Used To Add Required Field Validator Control
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
private RequiredFieldValidator RequiredFieldValidatorControl(string ID)
{
rfv.CssClass = VALIDATORSTYLESHEET;
rfv.Display = ValidatorDisplay.Dynamic;
rfv.ControlToValidate = ID;
if (!object.Equals(this.PropertyCollection[EMSDataGridExtendedProperties.RequiredErrorMessage], null))
{
else
{
return rfv;
/// <summary>
/// Helper Function Used Add The Range Validator Control
/// </summary>
/// <param name="ID"></param>
/// <param name="ValDataType"></param>
/// <param name="MaxValue"></param>
/// <param name="MinValue"></param>
/// <returns></returns>
private RangeValidator RangeValidatorControl(string ID, ValidationDataType ValDataType, object MaxValue, object MinValue)
{
rv.CssClass = VALIDATORSTYLESHEET;
rv.Display = ValidatorDisplay.Dynamic;
rv.Type = ValDataType;
rv.ControlToValidate = ID;
if (!Object.Equals(MaxValue, null))
{
else
{
if (!Object.Equals(MinValue, null))
{
else
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.RequiredErrorMessage], null))
{
else
{
return rv;
/// <summary>
/// Helper Function To Populate The Drop Down Box
/// </summary>
/// <param name="ddl"></param>
/// <param name="strDefaultData"></param>
/// <param name="columnname"></param>
/// <param name="columncaption"></param>
/// <param name="PropertyCollection"></param>
private void BindDropDown(DropDownList ddl, string strDefaultData, string columnname, string columncaption, System.Data.PropertyCollection PropertyCollection)
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.DataTable], null))
{
if (!object.Equals(dt.Rows[0][0], DBNull.Value))
{
dr[0] = DBNull.Value;
dr[1] = DROPDOWNDEFAULTTEXT;
dt.Rows.InsertAt(dr, 0);
ddl.DataSource = dt;
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.DataValueField], null))
{
else
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.DataTextField], null))
{
else
{
ddl.DataBind();
ddl.CssClass = DROPDOWNSTYLE;
ddl.SelectedValue = strDefaultData;
else
{
/// <summary>
/// Reads The Data From The DataItem And updates the bounded datasource
/// </summary>
public void EMSDataGridReadData()
{
this.ReadDataGridData(this.EditItemIndex);
/// <summary>
/// Reads The Data From The DataItem And updates the bounded datasource
/// </summary>
/// <param name="row"></param>
private void ReadDataGridData(int row)
{
//Update The DataSource With Latest Information
DataTable dt = ((DataView)this.DataSource).Table;
int Cell, BaseCell;
int Item;
if (object.Equals(dt, null)) return;
if (row == -1)
{
BaseCell = 1;
Cell = BaseCell;
Item = 0;
else
{
Cell = BaseCell;
Item = row;
//foreach(DataGridItem datagridItem in this.Items)
for (; Item < this.Items.Count; Item++)
{
row++;
for (int col = 0; col < dt.Columns.Count; col++)
{
{
{
{
{
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
break;
{
for (int ctl = 0; ctl < this.Items[Item].Cells[Cell].Controls.Count; ctl++)
{
{
else if (this.Items[Item].Cells[Cell].Controls[ctl] is Literal)
{
else if (this.Items[Item].Cells[Cell].Controls[ctl] is DropDownList)
{
else
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
{
{
{
else
{
else
{
break;
if (!object.Equals(dt.Columns[col].ExtendedProperties[EMSDataGridExtendedProperties.MultipleControl], null))
{
break;
{
{
{
break;
{
{
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
{
{
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
{
{
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
{
{
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
{
{
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
{
{
{
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
{
{
this.ViewState[HIDDENCONCURRENCYSTATE] = null;
else
{
{
{
{
//DBValue = SetValidDBValue(((TextBox)this.Items[Item].Cells[Cell].Controls[ctl]).Text);
if (!dt.Columns[col].AllowDBNull && object.Equals(DBValue, DBNull.Value))
{
else
{
break;
//Incrementing The Cell
if (this.EditItemIndex == -1)
{
{
else
{
else
{
if (this.EditItemIndex != -1)
{
/// <summary>
/// Adds The DataControl For The DataItem If The DataType Is DataTime
/// </summary>
/// <param name="e"></param>
/// <param name="cells"></param>
private void AddDateControl(DataGridItemEventArgs e, int cells)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
//Putting The Range Validator To Handle Arthi OverFlow Error
switch (dt.Columns[i].DataType.ToString())
{
for (int ctl = 0; ctl < e.Item.Cells[cells].Controls.Count; ctl++)
{
{
{
//Storing The Textbox Information In ElipseTextBox
textbox = ((TextBox)e.Item.Cells[cells].Controls[ctl]);
if (!object.Equals(textbox, null))
{
Literal literal = new Literal();
literal.Text = "&nbsp;"
e.Item.Cells[cells].Controls.Add(literal);
ImageButton ibtnCalendarStartDate = new ImageButton();
ibtnCalendarStartDate.ImageUrl = this.ResolveUrl(System.Configuration.ConfigurationSettings.AppSettings["CalenderImage"]);
ibtnCalendarStartDate.Attributes.Add("onclick", "getCalendar(document.forms[0].item(\"" + textbox.ClientID + "\"), '" + this.ResolveUrl(System.Configuration.ConfigurationSettings.AppSettings["CalenderControl"]) + "'); return false;");
e.Item.Cells[cells].Controls.Add(ibtnCalendarStartDate);
else if (e.Item.Cells[cells].Controls[ctl] is HtmlInputButton && !object.Equals(textbox, null))
{
break;
cells++;
/// <summary>
/// Adds The Functionality for Each DataItem To Maintain The checkbox state across pages
/// </summary>
/// <param name="e"></param>
private void AddCheckBoxState(DataGridItemEventArgs e)
{
int intCurrentPageRowCount = 0;
string strCheckBoxState = string.Empty;
string strCheckBoxStateCount = string.Empty;
HtmlInputHidden hidCheckBoxState = new HtmlInputHidden();
//                                                
//This Part of Code Is Used For Mainting Checkbox State Across Pages                                    
if (this.blnCheckBoxState)
{
{
this.dsCheckBoxState = new DataSet();
//Creating The Instance of StringReader Class
StringReader sr = new StringReader(this.ViewState[this.strHiddenCheckBoxState].ToString());
//Loading The DataSet From StringReader Class
this.dsCheckBoxState.ReadXml(sr);
//
switch (e.Item.ItemType)
{
CheckBox chkHeader = (CheckBox)e.Item.Cells[this.intCheckBoxColumn].Controls[0];
//
//chkHeader.ID = this.ID + e.Item.ItemIndex + e.Item.Cells[this.intCheckBoxColumn];
//
chkHeader.Attributes.Add("onclick", "EMSGridCheckAll(document.all." + this.ClientID + ", document.forms[0]." + chkHeader.ClientID + ");EMSGridCheckboxState(document.all." + this.ClientID + ", " + this.CurrentPageIndex + ", '" + this.strHiddenCheckBoxState + "', '" + this.strNoOfRecordsCheckBoxState + "', '" + this.strCheckBoxStateCount + "', document.forms[0].item(\"" + chkHeader.ClientID + "\")," + this.PageSize + ",'" + this.strHiddenPreviousPage + "');");
//
strHeaderCheckBoxId = chkHeader.ClientID;
if (!this.blnClearGridStatus)
{
//Make The Previous Pages Checkbox Checked If Records Exists For Them
if (!object.Equals(this.dsCheckBoxState, null))
{
if (this.dsCheckBoxState.Tables.Count == 1)
{
if (this.dsCheckBoxState.Tables[0].Rows.Count > 0)
{
//                                        
if ((dr.Length) == this.PageSize)
{
else
{
//
if (!object.Equals(HttpContext.Current.Request[this.strNoOfRecordsCheckBoxState], null))
{
{
{
{
DataRow[] dr = dsCheckBoxState.Tables[0].Select("PageNumber" + "='" + this.CurrentPageIndex + "'");
//                                                                                                                                                                                                                                                                                                                                                                                                                                                        
intCurrentPageRowCount = dr.Length;
//
strCheckBoxState = intCurrentPageRowCount.ToString();
//
if (!object.Equals(this.dsCheckBoxState, null))
{
{
{
{
intRowCount = this.dsCheckBoxState.Tables[0].Rows.Count - intCurrentPageRowCount;
//
strCheckBoxStateCount = intRowCount.ToString();
//Adding The Hidden Control To The Page
HtmlInputHidden hid = new HtmlInputHidden();
hid.ID = HIDDENCHECKSTATE;
//
this.Controls.Add(hid);
//Adding The Hidden Control To The Page
hidCheckBoxState.ID = HIDDENNORECORDSCHECKBOXSTATE;
hidCheckBoxState.Value = strCheckBoxState;
//
this.Controls.Add(hidCheckBoxState);
//Adding the Hidden Control to The page
HtmlInputHidden hidCheckBoxStateCount = new HtmlInputHidden();
hidCheckBoxStateCount.ID = HIDDENCHECKBOXSTATECOUNT;
hidCheckBoxStateCount.Value = strCheckBoxStateCount;
//
this.Controls.Add(hidCheckBoxStateCount);
//
//this.Controls.Add(hidCheckBoxState);
HtmlInputHidden hidPreviousPage = new HtmlInputHidden();
hidPreviousPage.ID = HIDDENPREVIOUSPAGE;
//
this.Controls.Add(hidPreviousPage);
break;
{
CheckBox chk = (CheckBox)e.Item.Cells[this.intCheckBoxColumn].Controls[0];
//
chk.Enabled = true;
chk.Checked = false;
chk.ID = this.ID + e.Item.ItemIndex + this.intCheckBoxColumn;
if (!this.blnClearGridStatus)
{
{
{
{
{
DataRow[] dr = dsCheckBoxState.Tables[0].Select("PageNumber" + "='" + this.CurrentPageIndex + "'");
//                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
intCurrentPageRowCount = dr.Length;
//
hidCheckBoxState.Value = intCurrentPageRowCount.ToString();
else
{
else
{
else
{
//Make The Previous Pages Checkbox Checked If Records Exists For Them
if (!object.Equals(this.dsCheckBoxState, null))
{
if (this.dsCheckBoxState.Tables.Count == 1)
{
if (this.dsCheckBoxState.Tables[0].Rows.Count > 0)
{
//                                            
if (dr.Length == 1)
{
else
{
//                                                                                                                                                                                                    
chk.Attributes.Add("onclick", "EMSGridCheckboxState(document.all." + this.ClientID + ", " + this.CurrentPageIndex + ", '" + this.strHiddenCheckBoxState + "', '" + this.strNoOfRecordsCheckBoxState + "', '" + this.strCheckBoxStateCount + "', document.forms[0].item(\"" + this.strHeaderCheckBoxId + "\"), " + this.PageSize + ",'" + this.strHiddenPreviousPage + "');");
break;
/// <summary>
/// Helper Function Adds The Client Side Functionality For Checkbox State
/// </summary>
private void AddClientSideScript()
{
sbCheckAll.Append("<script>");
sbCheckAll.Append("function EMSGridCheckAll(EmsGridId, HeaderCheckBox)");
sbCheckAll.Append("{");
sbCheckAll.Append("for(var row = 1; row < EmsGridId.rows.length; row++)");
sbCheckAll.Append("{");
sbCheckAll.Append("for(var col=0; col < EmsGridId.rows[row].cells.length; col++)");
sbCheckAll.Append("{");
sbCheckAll.Append("for(cells = 0; cells < EmsGridId.rows[row].cells(col).children.length; cells++)");
sbCheckAll.Append("{");
sbCheckAll.Append("if(EmsGridId.rows[row].cells(col).children[cells].type == \"checkbox\")");
sbCheckAll.Append("{");
sbCheckAll.Append("EmsGridId.rows[row].cells(col).children[cells].checked = HeaderCheckBox.checked"); ;
sbCheckAll.Append("}");
sbCheckAll.Append("break;");
sbCheckAll.Append("}");
sbCheckAll.Append("}");
sbCheckAll.Append("}");
sbCheckAll.Append("}");
sbCheckAll.Append("</script>");
StringBuilder sbCheckBoxState = new StringBuilder();
sbCheckBoxState.Append("<script>");
//Adding The Function Attribute
sbCheckBoxState.Append("function EMSGridCheckboxState(EmsGridId, CurrentPageIndex, hidCheckBoxState, hidNoOfRecordsCheckBoxState, hidCheckRecordsCount, HeaderCheckBox, PageSize, PreviousPage)");
//Opening The function Braces
sbCheckBoxState.Append("{");
//Validating If The DataGrid Exisits
sbCheckBoxState.Append("if(EmsGridId == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("alert('Invalid DataGrid Name');");
sbCheckBoxState.Append("return");
sbCheckBoxState.Append("}");
//Validating If The CurrentPageIndex Exisits
sbCheckBoxState.Append("if(CurrentPageIndex == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("alert('Invalid Page Index');");
sbCheckBoxState.Append("return;");
sbCheckBoxState.Append("}");
//Converting hidCheckBoxState To An Object
sbCheckBoxState.Append("hidCheckBoxState = eval('document.forms[0].item(\"' + hidCheckBoxState +  '\")');");
//Converting hidNoOfRecordsCheckBoxState To An Object
sbCheckBoxState.Append("hidNoOfRecordsCheckBoxState = eval('document.forms[0].item(\"' + hidNoOfRecordsCheckBoxState +  '\")');");
//PreviousPage
sbCheckBoxState.Append("PreviousPage = eval('document.forms[0].item(\"' + PreviousPage +  '\")');");
//
sbCheckBoxState.Append("hidNoOfRecordsCheckBoxState.value = 0;");
//
sbCheckBoxState.Append("hidCheckRecordsCount = eval('document.forms[0].item(\"' + hidCheckRecordsCount +  '\")');");
//Validating if the converted hidCheckBoxState is an object
sbCheckBoxState.Append("if(hidCheckBoxState == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("alert('Invalid Check Box State Control');");
sbCheckBoxState.Append("return;");
sbCheckBoxState.Append("}");
//Validating if the converted hidNoOfRecordsCheckBoxState is an object
sbCheckBoxState.Append("if(hidNoOfRecordsCheckBoxState == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("alert('Invalid No Of Records Check Box State Control');");
sbCheckBoxState.Append("return;");
sbCheckBoxState.Append("}");
//Validating if the converted hidNoOfRecordsCheckBoxState is an object
sbCheckBoxState.Append("if(hidCheckRecordsCount == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("alert('Invalid Check Records Count Control');");
sbCheckBoxState.Append("return;");
sbCheckBoxState.Append("}");
//Validating if the PreviousPage Control Exists
sbCheckBoxState.Append("if(PreviousPage == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("alert('Invalid Previous Page Control');");
sbCheckBoxState.Append("return;");
sbCheckBoxState.Append("}");
//Validating if the converted hidCheckBoxState's value is null
sbCheckBoxState.Append("if(hidCheckBoxState.value == \"\")");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("var data = CurrentPageIndex;");
sbCheckBoxState.Append("var pkdata;");
sbCheckBoxState.Append("for(var row = 1; row < EmsGridId.rows.length; row++)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("for(var col=0; col < EmsGridId.rows[row].cells.length; col++)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("for(cells = 0; cells < EmsGridId.rows[row].cells(col).children.length; cells++)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(EmsGridId.rows[row].cells(col).children[cells].type == \"checkbox\")");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(EmsGridId.rows[row].cells(col).children[cells].checked)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(pkdata == null)");
sbCheckBoxState.Append("{");
//sbCheckBoxState.Append("alert(EmsGridId.rows[row].id.length);");
sbCheckBoxState.Append("if(EmsGridId.rows[row].id.length > 0)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("pkdata = EmsGridId.rows[row].id;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
//sbCheckBoxState.Append("alert(EmsGridId.rows[row].id.length);");
sbCheckBoxState.Append("if(EmsGridId.rows[row].id.length > 0)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("pkdata = pkdata + \"^\" + EmsGridId.rows[row].id;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("break;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("if(pkdata == null)");
sbCheckBoxState.Append("{");
//
sbCheckBoxState.Append("PreviousPage.value = CurrentPageIndex;");
//
sbCheckBoxState.Append("return;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
//
sbCheckBoxState.Append("PreviousPage.value = CurrentPageIndex;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("hidCheckBoxState.value = data +\"~\"+ pkdata;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("pagespliter = hidCheckBoxState.value.split(\"|\");");
sbCheckBoxState.Append("var data;");
sbCheckBoxState.Append("for(var page = 0;  page++)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("pageIndex   = pagespliter[page].split(\"~\");");
sbCheckBoxState.Append("if(pageIndex[0] == CurrentPageIndex)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("for(var row = 1; row < EmsGridId.rows.length; row++)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("for(var col=0; col < EmsGridId.rows[row].cells.length; col++)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("for(cells = 0; cells < EmsGridId.rows[row].cells(col).children.length; cells++)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(EmsGridId.rows[row].cells(col).children[cells].type == \"checkbox\")");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(EmsGridId.rows[row].cells(col).children[cells].checked)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(data == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(EmsGridId.rows[row].id != \"\")");
sbCheckBoxState.Append("{");
//sbCheckBoxState.Append("alert(EmsGridId.rows[row].id.length);");
sbCheckBoxState.Append("if(EmsGridId.rows[row].id.length > 0)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("data = EmsGridId.rows[row].id;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(EmsGridId.rows[row].id != \"\")");
sbCheckBoxState.Append("{");
//sbCheckBoxState.Append("alert(EmsGridId.rows[row].id.length);");
sbCheckBoxState.Append("if(EmsGridId.rows[row].id.length > 0)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("data = data + \"^\" + EmsGridId.rows[row].id;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("break;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("if(data == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("pagespliter[page] = \"\"");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("pageIndex[1] = data;");
sbCheckBoxState.Append("pagespliter[page] = pageIndex.join(\"~\");");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("break;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("hidCheckBoxState.value = pagespliter.join(\"|\");");
//
sbCheckBoxState.Append("PreviousPage.value = CurrentPageIndex;");
sbCheckBoxState.Append("}");
//Adding The Number Of Rows Checked Across EMS
sbCheckBoxState.Append("var noofrows = hidCheckBoxState.value;");
sbCheckBoxState.Append("var noofrows = noofrows.split(\"~\");");
sbCheckBoxState.Append("if(noofrows.length == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("hidNoOfRecordsCheckBoxState.value = 0;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("if(noofrows.length == 2)");
sbCheckBoxState.Append("{");
//sbCheckBoxState.Append("alert(noofrows[1]);");
sbCheckBoxState.Append("noofrows[1] = noofrows[1].split(\"^\");");
sbCheckBoxState.Append("if(noofrows[1].length == null)");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("hidNoOfRecordsCheckBoxState.value = 0;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("hidNoOfRecordsCheckBoxState.value = noofrows[1].length;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("hidNoOfRecordsCheckBoxState.value = 0;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("}");
//sbCheckBoxState.Append("if(parseInt(hidNoOfRecordsCheckBoxState.value) == 20)");
//sbCheckBoxState.Append("{");
//            sbCheckBoxState.Append("PageSize = PageSize + 1");
//sbCheckBoxState.Append("}");
//sbCheckBoxState.Append("alert(PageSize); alert(hidNoOfRecordsCheckBoxState.value);alert(EmsGridId.rows.length);");
sbCheckBoxState.Append("if((PageSize) == parseInt(hidNoOfRecordsCheckBoxState.value))");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("HeaderCheckBox.checked = true;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else if((EmsGridId.rows.length - 3) == parseInt(hidNoOfRecordsCheckBoxState.value))");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("HeaderCheckBox.checked = true;");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("else");
sbCheckBoxState.Append("{");
sbCheckBoxState.Append("HeaderCheckBox.checked = false;");
sbCheckBoxState.Append("}");
//sbCheckBoxState.Append("alert('Current Records =' + hidNoOfRecordsCheckBoxState.value);");
//sbCheckBoxState.Append("alert('Total Records = ' + hidCheckRecordsCount.value);");
//Closing The function Braces
//sbCheckBoxState.Append("alert(PreviousPage.value);");
//sbCheckBoxState.Append("alert('Hello');");
sbCheckBoxState.Append("}");
sbCheckBoxState.Append("</script>");
this.Page.RegisterClientScriptBlock("sbCheckAll", sbCheckAll.ToString());
this.Page.RegisterClientScriptBlock("sbCheckBoxState", sbCheckBoxState.ToString());
#endregion
/// <summary>
/// Implementing the DataGrid Template Class
/// </summary>
public class DataGridTemplate : ITemplate
{
/// <summary>
/// ListItemType Variable Declaration
/// </summary>
ListItemType listitemtype;
/// <summary>
/// columnnumber Variable Declaration
/// </summary>
int columnnumber;
/// <summary>
/// columnname Variable Declaration
/// </summary>
string columnname;
/// <summary>
/// columncaption Variable Declaration
/// </summary>
string columncaption;
/// <summary>
/// columntype Variable Declaration
/// </summary>
string columntype;
/// <summary>
/// columnmaxlength Variable Declaration
/// </summary>
int columnmaxlength;
/// <summary>
/// allowsort Variable Declaration
/// </summary>
bool allowsort;
/// <summary>
/// headercssclass Variable Declaration
/// </summary>
string headercssclass;
/// <summary>
/// blnFullEditable Variable Declaration
/// </summary>
bool blnFullEditable;
/// <summary>
/// blnReadOnly Variable Declaration
/// </summary>
bool blnReadOnly;
/// <summary>
/// blnAllowDBNull Variable Declaration
/// </summary>
bool blnAllowDBNull;
/// <summary>
/// blnEnhanceEdit Variable Declaration
/// </summary>
bool blnEnhanceEdit;
/// <summary>
///  cellname Variable Declaration
/// </summary>
string cellname;
/// <summary>
/// guid Varaible Declaration
/// </summary>
string guid;
/// <summary>
/// PropertyCollection Variable Declaration
/// </summary>
System.Data.PropertyCollection PropertyCollection;
/// <summary>
/// RequiredFieldValidator style sheet declaration
/// </summary>
const string VALIDATORSTYLESHEET = "RequiredFieldValidator"
/// <summary>
/// RangeValidator Error Message
/// </summary>
const string RANGEERRORMESSAGE = "<BR><BLINK>||Invalid Data||</BLINK>"
/// <summary>
/// Required Field Error Message
/// </summary>
const string REQUIREDERRORMESSAGE = "<BR><BLINK>||Required||</BLINK>"
/// <summary>
/// DropDown List Default Value
/// </summary>
const string DROPDOWNDEFAULTTEXT = "||------SELECT------||"
/// <summary>
/// ReadOnly TextBox Style
/// </summary>
const string READONLYTEXTBOXSTYLE = "ReadOnlyTextBoxStyle"
/// <summary>
/// Range Validator For Decimal field Max Value
/// </summary>
string DecimalMaxValue = System.Configuration.ConfigurationSettings.AppSettings["DecimalMaxValue"];
/// <summary>
/// Range Validator For Decimal field Min Value
/// </summary>
string DecimalMinValue = System.Configuration.ConfigurationSettings.AppSettings["DecimalMinValue"];
/// <summary>
/// CheckBoxState Variable Declaration
/// </summary>
bool blnCheckBoxState;
/// <summary>
/// CheckBox Column Variable Declaration
/// </summary>
int intCheckBoxColumn;
#endregion
#region Public Method Of This Class
/// <summary>
/// contractor
/// </summary>
/// <param name="listItemType">The Type Of Item To Be Added</param>
/// <param name="columnName">Name Of The Column</param>
/// <param name="columnCaption">Column Heading</param>
/// <param name="columnNumber">Column Number</param>
/// <param name="columnType">DataType Of The Column</param>
/// <param name="allowSort">If Sorting Is Enabled</param>
/// <param name="headerCssClass">Style Sheet Class</param>
/// <param name="blnFullEditable">If Fully Editable</param>
/// <param name="blnReadOnly"></param>
/// <param name="PropertyCollection"></param>
/// <param name="AllowDBNull"></param>
/// <param name="blnEnhanceEdit"></param>
/// <param name="strcellname"></param>
/// <param name="columnmaxlength"></param>
/// <param name="blnCheckBoxState"></param>
/// <param name="intCheckBoxColumn"></param>
public DataGridTemplate(ListItemType listItemType, string columnName, string columnCaption, int columnNumber, string columnType, bool allowSort, string headerCssClass, bool blnFullEditable, bool blnReadOnly, System.Data.PropertyCollection PropertyCollection, bool AllowDBNull, bool blnEnhanceEdit, string strcellname, int columnmaxlength, bool blnCheckBoxState, int intCheckBoxColumn)
{
this.listitemtype = listItemType;
//set the column number
this.columnnumber = columnNumber;
//set the column name
this.columnname = columnName;
//set the column caption
this.columncaption = columnCaption;
//set the column type
this.columntype = columnType;
//set the sort property
this.allowsort = allowSort;
//set the header css class
this.headercssclass = headerCssClass;
//set the FullEditable
this.blnFullEditable = blnFullEditable;
//Used Is A Column Is ReadOnly
this.blnReadOnly = blnReadOnly;
//Any Other Specific Data Column Collection
this.PropertyCollection = PropertyCollection;
//Puts A Required Field Validator Control
this.blnAllowDBNull = AllowDBNull;
//Puts The Appropriate Validator Controls
this.blnEnhanceEdit = blnEnhanceEdit;
//Giving a unique name to a control
this.cellname = strcellname;
//Maxlength Of The Column
this.columnmaxlength = columnmaxlength;
//CheckBoxState
this.blnCheckBoxState = blnCheckBoxState;
this.intCheckBoxColumn = intCheckBoxColumn;
/// <summary>
/// implement the InstantiateIn method
/// </summary>
/// <param name="container"></param>
public void InstantiateIn(System.Web.UI.Control container)
{
//for listitem type, set the template style
#region Setting Template Style
switch (listitemtype)
{
case ListItemType.Header:
{
{
{
container.Controls.Add(chkHeader);
else
{
{
container.Controls.Add(lc);
else
{
linkButton.Text = columncaption;
linkButton.CommandName = "sort"
linkButton.CommandArgument = columnname;
linkButton.CssClass = headercssclass;
container.Controls.Add(linkButton);
//TableCell x = new TableCell();
break;
{
container.Controls.Add(lc);
else
{
linkButton.Text = columncaption;
linkButton.CommandName = "sort"
linkButton.CommandArgument = columnname;
linkButton.CssClass = headercssclass;
container.Controls.Add(linkButton);
//TableCell x = new TableCell();
break;
else
{
{
{
else
{
container.Controls.Add(lc);
else
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CustomColumnHeading], null))
{
else
{
linkButton.CommandName = "sort"
linkButton.CommandArgument = columnname;
linkButton.CssClass = headercssclass;
container.Controls.Add(linkButton);
//TableCell x = new TableCell();
break;
case ListItemType.Item:
{
//check the column type and set the control based on the datatype
switch (columntype)
{
lc.DataBinding += new EventHandler(lc_SelectedDropDown);
container.Controls.Add(lc);
DropDownList dp = new DropDownList();
this.BindDropDown(dp);
dp.SelectedValue = lc.Text;
//dp.PreRender += new EventHandler(ddl_SelectedDropDown);
container.Controls.Add(dp);
break;
//tb.ID = this.cellname;
if (this.columnmaxlength > 0)
{
tb.DataBinding += new EventHandler(tb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb);
//Adding The Elipse Button If Required
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.ElipseButton], null))
{
elipseButton.Value = "..."
elipseButton.Attributes.Add("Style", "CustomButtonStyle");
elipseButton.Attributes.Add("title", "||Click Here To Open Popup||");
container.Controls.Add(elipseButton);
break;
cb.DataBinding += new EventHandler(cb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(cb);
break;
tb1.DataBinding += new EventHandler(tb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb1);
break;
tb2.DataBinding += new EventHandler(tb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
//Adding The TextBox
container.Controls.Add(tb2);
break;
tb3.DataBinding += new EventHandler(tb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb3);
break;
//tb4.ID = this.cellname;
tb4.DataBinding += new EventHandler(tb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb4);
break;
tb5.DataBinding += new EventHandler(tb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb5);
break;
tb6.DataBinding += new EventHandler(tb_DataBinding);
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb6);
break;
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
else
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
else
{
tb7.ReadOnly = true;
tb7.DataBinding += new EventHandler(tb7_DataBinding);
container.Controls.Add(tb7);
break;
#endregion
else
{
switch (columntype)
{
cb.DataBinding += new EventHandler(cb_DataBinding);
cb.Enabled = false;
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(cb);
break;
{
else
{
container.Controls.Add(lc);
break;
container.Controls.Add(lc);
break;
#endregion
break;
case ListItemType.EditItem:
if (this.blnEnhanceEdit && !this.blnReadOnly)
{
//check the column type and set the control based on the datatype
switch (columntype)
{
{
lc.DataBinding += new EventHandler(lc_SelectedDropDown);
container.Controls.Add(lc);
DropDownList dp = new DropDownList();
container.Controls.Add(dp);
break;
tb.MaxLength = this.columnmaxlength;
tb.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb);
//Adding The Elipse Button If Required
if (!object.Equals(PropertyCollection[EMSDataGridExtendedProperties.ElipseButton], null))
{
elipseButton.Value = "..."
elipseButton.Attributes.Add("Style", "CustomButtonStyle");
elipseButton.Attributes.Add("title", "||Click Here To Open Popup||");
container.Controls.Add(elipseButton);
break;
cb.DataBinding += new EventHandler(cb_DataBinding);
//cb.ID = this.cellname;
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(cb);
break;
//tb1.ID = this.cellname;
tb1.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb1);
break;
tb2.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb2);
break;
tb3.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb3);
break;
tb4.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb4);
break;
tb5.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb5);
break;
tb6.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
container.Controls.Add(tb6);
break;
tb7.DataBinding += new EventHandler(tb_DataBinding);
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.Width], null))
{
else
{
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.CssClass], null))
{
else
{
tb7.ReadOnly = true;
container.Controls.Add(tb7);
break;
#endregion
else
{
//check the column type and set the control based on the datatype
switch (columntype)
{
//Bind Data
container.Controls.Add(dp);
break;
tb.DataBinding += new EventHandler(tb_DataBinding);
container.Controls.Add(tb);
break;
cb.DataBinding += new EventHandler(cb_DataBinding);
container.Controls.Add(cb);
break;
tb1.DataBinding += new EventHandler(tb_DataBinding);
container.Controls.Add(tb1);
break;
tb2.DataBinding += new EventHandler(tb_DataBinding);
container.Controls.Add(tb2);
break;
tb3.DataBinding += new EventHandler(tb_DataBinding);
container.Controls.Add(tb3);
break;
tb4.DataBinding += new EventHandler(tb_DataBinding);
container.Controls.Add(tb4);
break;
tb5.DataBinding += new EventHandler(tb_DataBinding);
container.Controls.Add(tb5);
break;
tb6.DataBinding += new EventHandler(tb_DataBinding);
container.Controls.Add(tb6);
break;
#endregion
break;
case ListItemType.Footer:
break;
#endregion
#endregion
#region Events Raised By The InstantiateIn Methods Implementation
/// <summary>
/// Label Binding Data Event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lc_DataBinding(object sender, EventArgs e)
{
{
DataRowView container = (DataRowView)((DataGridItem)literal.NamingContainer).DataItem;
literal.Text = container.Row.ItemArray[columnnumber].ToString();
Regex re = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
if (re.IsMatch(literal.Text)) // for email address add a mailto: hyperlink
{
/// <summary>
/// Event Is Raised To Find The Description Of UniqueIdentifiers
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lc_SearchDataBinding(object sender, EventArgs e)
{
{
DataRowView container = (DataRowView)((DataGridItem)literal.NamingContainer).DataItem;
guid = container.Row.ItemArray[columnnumber].ToString();
literal.ID = guid;
literal.Text = this.SearchDataTable(this.PropertyCollection[EMSDataGridExtendedProperties.DataTable], this.PropertyCollection[EMSDataGridExtendedProperties.DataColumnSearch], this.PropertyCollection[EMSDataGridExtendedProperties.DataTextField], guid);
else
{
/// <summary>
/// Event Is Raised To Set The Default Selected Value
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lc_SelectedDropDown(object sender, EventArgs e)
{
DataRowView container = (DataRowView)((DataGridItem)literal.NamingContainer).DataItem;
if (!object.Equals(container.Row.ItemArray[columnnumber], Guid.Empty))
{
//this.strSelectedValue = container.Row.ItemArray[columnnumber].ToString();
/// <summary>
/// This Event Is Used For Selected DropDown
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ddl_SelectedDropDown(object sender, EventArgs e)
{
DataRowView container = (DataRowView)((DataGridItem)ddl.NamingContainer).DataItem;
//ddl.SelectedValue = this.strSelectedValue;
//this.strSelectedValue = string.Empty;
/// <summary>
/// Used To Set The Value For The TextBox Based On The DataType
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tb_DataBinding(object sender, EventArgs e)
{
{
DataRowView container = (DataRowView)((DataGridItem)tb.NamingContainer).DataItem;
tb.Text = container.Row.ItemArray[columnnumber].ToString();
if (!Object.Equals(PropertyCollection[EMSDataGridExtendedProperties.ReadOnly], null))
{
{
if (container.Row[PropertyCollection[EMSDataGridExtendedProperties.ReadOnly].ToString()].GetType().ToString() == "System.Boolean")
{
tb.ReadOnly = blnFlag;
//Setting ReadOnly Style Of The TextBox
if (blnFlag)
{
{
else
{
/// <summary>
/// Used To Set The Value For The TextBox Based On The DataType
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tb7_DataBinding(object sender, EventArgs e)
{
{
DataRowView container = (DataRowView)((DataGridItem)tb.NamingContainer).DataItem;
tb.Text = GetValidDate(container.Row.ItemArray[columnnumber]).ToString();
tb.ReadOnly = true;
tb.CssClass = READONLYTEXTBOXSTYLE;
/// <summary>
/// Used To Set The CheckBox Value
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cb_DataBinding(object sender, EventArgs e)
{
{
DataRowView container = (DataRowView)((DataGridItem)cb.NamingContainer).DataItem;
if (!object.Equals(container.Row.ItemArray[columnnumber], DBNull.Value))
{
#endregion
#region Helper Function Used By This Class
/// <summary>
/// Helper Function Used Populate The DropDown Box
/// </summary>
/// <param name="ddl"></param>
private void BindDropDown(DropDownList ddl)
{
{
if (!object.Equals(dt.Rows[0][0], DBNull.Value))
{
dr[0] = DBNull.Value;
dr[1] = DROPDOWNDEFAULTTEXT;
dt.Rows.InsertAt(dr, 0);
ddl.DataSource = dt;
if (!object.Equals(this.PropertyCollection[EMSDataGridExtendedProperties.DataValueField], null))
{
else
{
if (!object.Equals(this.PropertyCollection[EMSDataGridExtendedProperties.DataTextField], null))
{
else
{
ddl.DataBind();
else
{
/// <summary>
/// Helper Function Used To Set The Description For The Guid
/// </summary>
/// <param name="objDataTable"></param>
/// <param name="objDataColumn"></param>
/// <param name="strId"></param>
/// <returns></returns>
private string SearchDataTable(object objDataTable, object objDataColumn, object objDataText, string strId)
{
if (strId.Length == 0)
{
//
if (!object.Equals(objDataTable, null))
{
{
if (dr.Length == 0)
{
else
{
//return dr[0][1].ToString();                        
else
{
else
{
/// <summary>
/// Helper Function Used For Date Conversion
/// </summary>
/// <param name="dtDate"></param>
/// <returns></returns>
public DateTime DateConvertor(string strDate)
{
return DateTime.ParseExact(strDate, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.None);
/// <summary>
/// Helper Function Used For Date Conversion
/// </summary>
/// <param name="dtDate"></param>
/// <returns></returns>
public string DateConvertor(DateTime dtDate)
{
/// <summary>
/// Helper Function Used For DataRow Value Conversion
/// </summary>
/// <param name="objDate"></param>
/// <returns></returns>
private object GetValidDate(object objDate)
{
{
else
{
/// <summary>
/// Helper Function Used For DataRow Value Conversion
/// </summary>
/// <param name="strValue"></param>
/// <returns></returns>
private object GetValidValue(string strValue)
{
if (strValue.Length == 0)
{
else
{
#endregion