Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
283 views
Hi Friends,
I need to perform insert,update,delete operation in radgrid by passing values from  external textboxes and external button click event in SQL DB statement.
Examples given in radgrid demo is on client side and also external form template mode.so its not useful,pls dont post me as refer this link in telerik demo.

In this code,I created radgrid.And an External textbox and external  radbuttons .On row select i pass the radgrid selected row  values to external textboxes using javascript.Now i need is when i click update ,insert,delete button ,based on textbox value,radgrid needs to binded,


I fir


Pls anyone  help on this matter ,here my code
<head runat="server">
    <title>Sales Dashboard</title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <link href="Skins/TreeView.SalesBlack.css" rel="stylesheet" type="text/css" />
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function RowSelected(sender, args) {
 
            
                document.getElementById("<%= tag_name.ClientID %>").innerHTML =
                  "Resource Name";
                document.getElementById("<%= tag_mobile.ClientID %>").innerHTML =
                  "Mobile No";
                document.getElementById("<%= tag_email.ClientID %>").innerHTML =
                  "E-Mail";
                document.getElementById("<%= tag_primary.ClientID %>").innerHTML =
                  "Primary Skill";
                document.getElementById("<%= tag_createdby.ClientID %>").innerHTML =
                  "Created By";
                 
 
                document.getElementById("<%= lbl_name.ClientID %>").innerHTML =
                  args.getDataKeyValue("ResourceName");
                document.getElementById("<%= lbl_mobile.ClientID %>").innerHTML =
                  args.getDataKeyValue("MobileNo");
                document.getElementById("<%= lbl_email.ClientID %>").innerHTML =
                  args.getDataKeyValue("EMail");
 
                document.getElementById("<%= lbl_primary.ClientID %>").innerHTML =
                  args.getDataKeyValue("PrimarySkill");
                document.getElementById("<%= lbl_createdby.ClientID %>").innerHTML =
                  args.getDataKeyValue("CreatedBy");
                 
                var txt_name = $find("txt_name");
                txt_name.set_value(args.getDataKeyValue("ResourceName"));
 
                var txt_mobile = $find("txt_mobile");
                txt_mobile.set_value(args.getDataKeyValue("MobileNo"));
 
 
                var txt_email = $find("txt_email");
                txt_email.set_value(args.getDataKeyValue("EMail"));
 
                var txt_primary = $find("txt_primary");
                txt_primary.set_value(args.getDataKeyValue("PrimarySkill"));
 
                var txt_createdby = $find("txt_createdby");
                txt_createdby.set_value(args.getDataKeyValue("CreatedBy"));
 
 
                var textbox = $find("txt_name");
                textbox.set_visible(false);
 
                var textbox1 = $find("txt_mobile");
 
                textbox1.set_visible(false);
 
                var textbox2 = $find("txt_email");
 
                textbox2.set_visible(false);
 
                var textbox4 = $find("txt_primary");
 
                textbox4.set_visible(false);
                var textbox3 = $find("txt_createdby");
 
                textbox3.set_visible(false);
 
                 
 
                document.getElementById("<%= lbl_name.ClientID %>").style.display = 'block';
                document.getElementById("<%= lbl_mobile.ClientID %>").style.display = 'block';
 
                document.getElementById("<%= lbl_email.ClientID %>").style.display = 'block';
                document.getElementById("<%= lbl_primary.ClientID %>").style.display = 'block';
 
                document.getElementById("<%= lbl_createdby.ClientID %>").style.display = 'block';
 
                document.getElementById("<%= edit.ClientID %>").style.display = "block";
 
            }
        </script>
        <script type="text/javascript">
            function edit(button, args) {
                debugger;
                var textbox = $find("txt_name");
                textbox.set_visible(true);
 
                var textbox1 = $find("txt_mobile");
                textbox1.set_visible(true);
                var textbox2 = $find("txt_email");
                textbox2.set_visible(true);
 
                var textbox4 = $find("txt_primary");
                textbox4.set_visible(true);
                var textbox3 = $find("txt_createdby");
                textbox3.set_visible(true);
 
                
 
                document.getElementById("<%= lbl_name.ClientID %>").style.display = 'none';
                document.getElementById("<%= lbl_mobile.ClientID %>").style.display = 'none';
                document.getElementById("<%= lbl_email.ClientID %>").style.display = 'none';
                document.getElementById("<%= lbl_primary.ClientID %>").style.display = 'none';
                document.getElementById("<%= lbl_createdby.ClientID %>").style.display = 'none';
                var btn = $find("edit");
                 btn.set_value = ("Update");
 
 
                button.set_autoPostBack(false);
//                var textbox = $find("txt_name");
//                textbox.set_visible(true);
//                var txtDate = $find("txt_name");
//                txtDate.set_value(args.getDataKeyValue("ResourceName"));
            }
 
        </script>
    </telerik:RadCodeBlock>
    <style type="text/css">
        .align
        {
            text-align: right;
        }
    </style>
    <style type="text/css">
    .edit
    {
        display:none;
    }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadStyleSheetManager runat="server" ID="RadStyleSheetManager1" />
    <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Scrollbars" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div style="width: 60%; height: 100%; float: left;">
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" ShowFooter="True"
            Style="outline: 0"  GroupingEnabled="true" ShowGroupPanel="true" AutoGenerateColumns="False"
            AllowSorting="True"  PageSize="15" Width="90%"  GridLines="None" CellPadding="0"
            OnNeedDataSource="RadGrid1_NeedDataSource" Skin="Black"
            >
            <MasterTableView ClientDataKeyNames="ResourceName,MobileNo ,EMail ,CreatedBy ,PrimarySkill"
                AutoGenerateColumns="false" ShowFooter="true" AllowFilteringByColumn="true" PagerStyle-Mode="NextPrevAndNumeric"
                TableLayout="Fixed">
                <Columns>
                    <telerik:GridBoundColumn DataField="ResourceName" HeaderText="Resource Name" UniqueName ="ResourceName" CurrentFilterFunction="equalto"
                        FilterDelay="1000" ShowFilterIcon="false" HeaderStyle-Width="120px" FilterControlWidth="105px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="MobileNo" HeaderStyle-Width="110px" HeaderText="Mobile"
                        FilterControlWidth="70px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="EMail" UniqueName ="email" HeaderStyle-Width="190px" HeaderText="E-Mail"
                        FilterControlWidth="120px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CreatedBy" HeaderText="Created By" CurrentFilterFunction="equalto"
                        FilterDelay="1000" ShowFilterIcon="false" FilterControlWidth="70px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PrimarySkill" UniqueName ="CurrentDesign" HeaderStyle-Width="190px" HeaderText="Primary Skill"
                        FilterControlWidth="0px">
                    </telerik:GridBoundColumn>
                      
 
                    
                </Columns>
            </MasterTableView>
            <ClientSettings  EnablePostBackOnRowClick="true" EnableRowHoverStyle="true" AllowDragToGroup="true"
                AllowColumnsReorder="true" ReorderColumnsOnClient="true" ColumnsReorderMethod="Reorder">
               
               <Selecting AllowRowSelect ="true"  />
              
                  <ClientEvents OnRowSelected="RowSelected"></ClientEvents>
                                        
                <Animation AllowColumnReorderAnimation="true" AllowColumnRevertAnimation="true">
                </Animation>
 
                  <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" />
            </ClientSettings>
        </telerik:RadGrid>
    </div>
    <div style="width: 40%; height: 80%; float: right;">
>
                                     
        <table style="margin: 50% auto auto 1px">
            <tr>
                <td>
                    <asp:Panel  ID="panel1" runat="server">
                        <table>
                            <tr>
                                <td>
                                    <asp:Label ID="tag_name" Font-Bold="True"  ForeColor="#B5B5B5" Font-Size="Small" runat="server"></asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="lbl_name" runat="server" ForeColor="WhiteSmoke" Font-Bold="True" Font-Size="Large"></asp:Label>
                                    <telerik:RadTextBox  ID="txt_name" runat="server" ForeColor="WhiteSmoke"  Skin="Black" Font-Size="Large">
                                    </telerik:RadTextBox>
                                     
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="tag_mobile" ForeColor="#B5B5B5" runat="server" Font-Bold="True" Font-Size="Small"></asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="lbl_mobile" ForeColor="WhiteSmoke" Font-Size="Large" runat="server"></asp:Label>
                                     <telerik:RadTextBox ID="txt_mobile" runat ="server" ForeColor ="WhiteSmoke" Font-Size="Large" Skin ="Black"   ></telerik:RadTextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="tag_email" ForeColor="#B5B5B5" runat="server" Font-Bold="True" Font-Size="Small"></asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="lbl_email" ForeColor="WhiteSmoke" Font-Size="Large" runat="server"></asp:Label>
                                         <telerik:RadTextBox ID="txt_email" runat ="server" ForeColor ="WhiteSmoke" Font-Size="Large"  Skin ="Black"  ></telerik:RadTextBox>
                                     
                                </td>
                            </tr>
                             
                            <tr>
                                <td>
                                    <asp:Label ID="tag_primary" ForeColor="#B5B5B5" runat="server" Font-Bold="True"
                                        Font-Size="Small"></asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="lbl_primary" ForeColor="WhiteSmoke" Font-Size="Large" runat="server"></asp:Label>
                                         <telerik:RadTextBox ID="txt_primary" runat ="server"
                                        ForeColor ="WhiteSmoke" Font-Size="Large"    Skin="Black"
                                         ></telerik:RadTextBox>
                                     
                                </td>
 
 
 
                            </tr>
 
                            <tr>
                                <td>
                                    <asp:Label ID="tag_createdby" ForeColor="#B5B5B5" runat="server" Font-Bold="True"
                                        Font-Size="Small"></asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="lbl_createdby"  ForeColor="WhiteSmoke" Font-Size="Large" runat="server"></asp:Label>
                                         <telerik:RadTextBox ID="txt_createdby" runat ="server" ForeColor ="WhiteSmoke" Font-Size="Large"    Skin="Black" ></telerik:RadTextBox>
                                     
                                </td>
                            </tr>
                            <tr>
                                <td>
                                <telerik:RadButton ID="edit" Width="35px" Text="Edit" style="display :none;"     OnClientClicked="edit"
                                        runat ="server" Skin="Forest"
                                         >
                                          
                                          
                                         </telerik:RadButton>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
 

My cs code is :

public partial class DMSdashboard : System.Web.UI.Page
    {
        SqlConnection conn = null;
        SqlDataReader reader = null;
        protected void Page_Load(object sender, EventArgs e)
        {
             
            
                 
 
             
        }
 
 
 
 
        private SqlDataReader ReadRecords(string query)
        {
            String con = @"Data Source=CHN374\SQLEXPRESS;Initial Catalog=Telerik;Integrated Security=true";
            conn = new SqlConnection(con);
            conn.Open();
            SqlCommand cmd = new SqlCommand(query, conn);
            reader = cmd.ExecuteReader();
            return reader;
        }
 
        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
 
 
            RadGrid1.DataSource = GetDataTable("select RecId, ResourceName ,MobileNo ,ContactNo ,EMail ,CreatedBy ,PrimarySkill,SecondarySkill from ResourceDocket");
             
        }
 
        public DataTable GetDataTable(string query)
        {
            String constring = @"Data Source=CHN374\SQLEXPRESS;
                        Initial Catalog=MyDB;
                        Integrated Security=True";
            SqlDataAdapter adapter = new SqlDataAdapter();
            DataTable myDataTable = new DataTable();
            using (SqlConnection con = new SqlConnection(constring))
            {
                adapter.SelectCommand = new SqlCommand(query, con);
                adapter.Fill(myDataTable);
            }
            return myDataTable;
        }
        protected void update_button_Click(object sender, EventArgs e)
        {
 
 
 
        }
 
  protected void insert_button_Click(object sender, EventArgs e)
        {
 
 
 
        }
  protected void delete_button_Click(object sender, EventArgs e)
        {
 
 
 
        }
 

    }
}

I need how to perform insert,update,delete on this external button click from values of  textbox1,textbox2 etc.. and pass it onto radgrid



I search it in many places proper solution is not found on website,Pls anyone help on this issue immediately,I posted two days before,still i never get any reply.If its not possible tell me its not possible.I wasted my time with this,
Andrey
Telerik team
 answered on 28 Nov 2012
9 answers
363 views
In IE7/IE8 RadGrid rows collapsing doesn't work in client mode using GroupByExpression.
Rows collapsing produces an "row overlapping" effect: hidden rows appear visible over the previous data.
Could anyone help me?
Tnx in advance
Radoslav
Telerik team
 answered on 28 Nov 2012
13 answers
254 views
How are you
I want to ask about important issue that i need to solve it as soon as possible
My scenario is RadGrid inside RadWindow, When I maximize The RadWindow, i need to maximIze RadGrid to fit the content of RadWindow also, when i return RadWindow to its normal size, i want RadGrid to return to its normal size
Also, PageSize DropDownList not working when Maximizing RadWindow;it works only when The RadWindow is in its normal size
My RadGrid uses UseStaticHeaders property to equal true and had fixed Width and Height
My RadWindow Markup is
<telerik:RadWindow ID="RadDeploymentWindow" Title="<%$ Resources:Text, DeploymentWizard %>" 
    runat="server" VisibleOnPageLoad="false" VisibleStatusbar="false" Width="535px" 
    Modal="true" Height="350px" Behaviors="Close,Move,Maximize,Reload " Skin="Windows7" 
    IconUrl="~/Images/icons/Enterprise.png"> 
    <ContentTemplate>
My RadGrid Markup is
<telerik:RadGrid ID="DeploymentGrid" Skin="Office2007" runat="server" AutoGenerateColumns="False"
                                        AllowSorting="True" PageSize="10" ShowStatusBar="True" CellSpacing="0" GridLines="Both"
                                        AllowPaging="True" OnNeedDataSource="RadGrid_NeedDataSource" Height="225px" Width="516px"
                                        <ClientSettings
                                            <Scrolling AllowScroll="true" UseStaticHeaders="true" /> 
                                        </ClientSettings
                                        <ExportSettings IgnorePaging="true" ExportOnlyData="true" OpenInNewWindow="true"
                                            HideStructureColumns="true" Excel-Format="Html" FileName="ErrorsAndWarnings"
                                        </ExportSettings
                                        <MasterTableView DataKeyNames="ObjectID" AutoGenerateColumns="false" CommandItemDisplay="Top"
                                            CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false"
                                            <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" /> 
                                            <ItemStyle Wrap="false" /> 
                                            <Columns
                                                <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" DataField="ObjectID"
                                                    HeaderText="ID"
                                                </telerik:GridBoundColumn
                                                <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" DataField="ObjectType"
                                                    HeaderText="Type"
                                                </telerik:GridBoundColumn
                                                <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" DataField="Name" HeaderText="Name"
                                                </telerik:GridBoundColumn
                                                <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" DataField="Attribute"
                                                    HeaderText="Attribute"
                                                </telerik:GridBoundColumn
                                                <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" DataField="Error" HeaderText="Description"
                                                </telerik:GridBoundColumn
                                                <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" DataField="ProposedSoluation"
                                                    HeaderText="Proposed Solution"
                                                </telerik:GridBoundColumn
                                                <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Center" DataField="Severity"
                                                    HeaderText="Severity"
                                                </telerik:GridBoundColumn
                                            </Columns
                                        </MasterTableView
                                        <ClientSettings
                                            <Resizing AllowColumnResize="True"></Resizing>                                             
                                        </ClientSettings
                                    </telerik:RadGrid>

Rohan
Top achievements
Rank 1
 answered on 28 Nov 2012
1 answer
138 views
I'm using Telerik RadEditor. Whenever I click on "Image Manager" it is opening DialogHandler.aspx in popup. How can I set the height of that popup?...Please help..its help.
Princy
Top achievements
Rank 2
 answered on 28 Nov 2012
3 answers
111 views
Hi,

I am using RadGrid in an Ajax updated pop up created using bPopup plugin for jQuery (http://dinbror.dk/bpopup/). I have the RadGrid and other controls in an Ajax UpdatePanel. The grid loads fine and shows the data. However when I click on a page number shown in the pager at the bottom of the grid it causes a full post-back, the page gets reloaded and the popup disappears. When I click the popup image button again I see the page number changed in the grid.

I looked at various threads regarding UpdatePanel and RadGrid and tried the following. None of it has helped.
1. Wrap the RadGrid in RadAjaxPanel.
2. Set grid viewstate = false when inside an update panel.
3. Set the update mode of update panel to conditional for all update panels on the page
4. Set RenderMode of the RadAjaxPanel and UpdatePanel to Inline.

Please help out.

Thanks and Regards,
Sameeksha
Andrey
Telerik team
 answered on 28 Nov 2012
2 answers
772 views
I just installed the Telerik free trial ASP.NET AJAX controls for Visual Studio 2010 Web Express.

I added the controls to the toolbar, and I can drop controls on the forms...

Problem is:

1) It always says Telerik.web.ui.[ControlName].... is not defined:
For Example: Type 'Telerik.Web.UI.Skins.RadButton' is not defined.

2) I cannot select the skins either...

Attempts thus far:

1) Added reference to all the .DLL's directly from the project
2) I was going to add a handler to the web.config, but not sure if this is still applicable in newer versions of the controls.

Not sure what I need to do next?
Eyup
Telerik team
 answered on 28 Nov 2012
1 answer
593 views
Hi all,
         In the code below Item Command of grid with IdrgAttendenceDetails is not getting fired when a link button present in a template column which is created dynamically in code behind is clicked. Please have a look at the code and specify a answer for it thank you.
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using Telerik.Web;
using Telerik.Web.UI;
using System.Data.SqlClient;
using MSI.Emailing;
using MSI.Logging;
using AttendenceManagement.Business_Layer;
 
namespace AttendenceManagement.Controls
{
    public partial class AttendenceDetailsGrid : System.Web.UI.UserControl
    {
        #region Properties Declarations
        /// <summary>
        /// Business Layer Objects Declared to Reterive or Save Data To DataBase.
        /// </summary>
        AttendenceDetailsDAO objAttendenceDetailsDAO = new AttendenceDetailsDAO();
        AttendenceDetailsEntities objAttendenceDetailsEntities = new AttendenceDetailsEntities();
        AttendenceDAO objAttendenceDAO = new AttendenceDAO();
        AttendenceEntities objAttendenceEntities = new AttendenceEntities();
        LoggingClass objLogging = new LoggingClass();
        Emailclass objEmailclass = new Emailclass();
        DataSet dsDetails = new DataSet();
        string strEmployeeId;
        #endregion
 
        #region Events
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                rdpFrom.MaxDate = DateTime.Now.AddDays(-1);
                rbClose.Image.IsBackgroundImage = true;
                rbClose.Image.ImageUrl = "~/CSS/TelerikCustomSkins/Grid/cancelbtn.png";
 
                if (!IsPostBack)
                {
                    rdpFrom.SelectedDate = DateTime.Now.AddMonths(-1);
 
                }
                LoadAttendenceGrid(true);
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Click Event to Select and Load Employee Attendence Details.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rbtnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                LoadAttendenceGrid(true);
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
        /// <summary>
        ///Attendence Grid ItemCommnad Event Fired to Load AttendenceDetailsPopup for a Particular Date of an Employee.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rgAttendenceDetails_ItemCommand(object sender, GridCommandEventArgs e)
        {
            try
            {
                rtbxComments.Text = string.Empty;
                string strMSIID;
                DateTime dtDate;
                if (e.CommandName == "AttendenceCheck")
                {
                    if (e.Item is GridDataItem)
                    {
                        GridDataItem item = (GridDataItem)e.Item;
 
                        strMSIID = item["Emp_ID"].Text;
                        CommonDAO objCommonDao = new CommonDAO();
                        DataSet dsUserDetails = objCommonDao.GetUserDetails(strMSIID);
                        if (dsUserDetails != null)
                        {
                            if (dsUserDetails.Tables.Count > 0)
                            {
                                if (dsUserDetails.Tables[0].Rows.Count > 0)
                                {
                                    lblEmployeeNameValue.Text = (string)dsUserDetails.Tables[0].Rows[0]["Employee_Name"];
                                }
                            }
                        }
                        lblEmployeeIdValue.Text = strMSIID;
                        dtDate = Convert.ToDateTime(e.CommandArgument.ToString());
                        lblDateValue.Text = dtDate.ToString("dd-MM-yyyy");
                        rwdAttendenceDetails.VisibleOnPageLoad = true;
                        objAttendenceDetailsEntities.EmployeeId = "0" + strMSIID; //Concatenating EmployeeId with 0 as defined in Database.
                        objAttendenceDetailsEntities.Date = dtDate;
                        Session["MSIId"] = strMSIID;
                        Session["Date"] = dtDate;
                        rcbxType.SelectedValue = "0";
                        LoadAttendenceGridPopUp();
                        LoadAttendenceGrid(false);
 
                        if (Session["AttendencePage"] != null)
                        {
                            if (Session["AttendencePage"].ToString() == "Attendence")
                            {
                                lblEmployeeNameValue.Enabled = false;
                                lblEmployeeIdValue.Enabled = false;
                                lblDateValue.Enabled = false;
                                rgMyAttendenceDetails.Enabled = false;
                                rtbxComments.Enabled = false;
                                rcbxType.Enabled = false;
                                objAttendenceEntities.MSIId = Session["MSIId"].ToString();
                                objAttendenceEntities.AttDate = Convert.ToDateTime(Session["Date"]);
                                DataSet dsAttType = new DataSet();
                                dsAttType = objAttendenceDAO.GetAttendenceType(objAttendenceEntities);
                                if (dsAttType != null)
                                {
                                    if (dsAttType.Tables.Count > 0)
                                    {
                                        if (dsAttType.Tables[0].Rows.Count > 0)
                                        {
                                            string strTypeName = (string)dsAttType.Tables[0].Rows[0]["Att_Type"];
                                            objAttendenceEntities.TypeName = strTypeName;
                                            DataSet dsTypeId = new DataSet();
                                            dsTypeId = objAttendenceDAO.GetTypeId(objAttendenceEntities);
                                            if (dsTypeId != null)
                                            {
                                                if (dsTypeId.Tables.Count > 0)
                                                {
                                                    if (dsTypeId.Tables[0].Rows.Count > 0)
                                                    {
                                                        rcbxType.SelectedValue = (string)dsTypeId.Tables[0].Rows[0]["TypeId"];
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Attendence Grid ItemDataBound Event Fired to set the Backcolor of the Control present in a Particular Cell of the Grid.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rgAttendenceDetails_ItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                //Not Header row
                if (e.Item.RowIndex > 0)
                {
                    for (int i = 1; i < e.Item.Cells.Count; i++)
                    {
                        if (e.Item.Cells[i].Controls.Count > 0)
                        {
                            LiteralControl lbl = (LiteralControl)e.Item.Cells[i].Controls[1];
                            LinkButton lnk = (LinkButton)e.Item.Cells[i].Controls[0];
                            if (lbl != null && lnk != null)
                            {
                                AttendenceDetailsDAO.AttendenceType objAttendenceType = AttendenceDetailsDAO.GetValueFromDescription(lbl.Text);
                                if (default(AttendenceDetailsDAO.AttendenceType) != objAttendenceType && objAttendenceType != AttendenceDetailsDAO.AttendenceType.Absent && objAttendenceType != AttendenceDetailsDAO.AttendenceType.HalfDayAbsent)
                                {
                                    lnk.Visible = false;
                                    e.Item.Cells[i].BackColor = AttendenceDetailsDAO.GetBackGroundColor(objAttendenceType);
                                }
                                else
                                {
                                    lbl.Visible = false;
                                    e.Item.Cells[i].BackColor = AttendenceDetailsDAO.GetBackGroundColor(objAttendenceType);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Click Event to Save the Status of the Employee For a Particular Date Selected for an Employee from the Attendence Details to DB.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rbOk_Click(object sender, EventArgs e)
        {
            try
            {
                objAttendenceEntities.MSIId = Session["MSIId"].ToString();
                objAttendenceEntities.AttDate = Convert.ToDateTime(Session["Date"]);
                objAttendenceEntities.CodeValue = rcbxType.Text;
                DataSet dsCodeId = new DataSet();
                dsCodeId = objAttendenceDAO.GetCodeId(objAttendenceEntities);
                if (dsCodeId != null && dsCodeId.Tables.Count > 0 && dsCodeId.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in dsCodeId.Tables[0].Rows)
                    {
                        objAttendenceEntities.AttTypeId = int.Parse(row["Code_ID"].ToString());
                    }
                }
                objAttendenceEntities.Comments = rtbxComments.Text;
                objAttendenceEntities.CreatedUserId = UserDetails.User.EmployeeId;
                objAttendenceDAO.SaveAttendenceDetails(objAttendenceEntities);
 
 
                if (rcbxType.Text == "Work From Home")
                {
                    string strLeadEmail = string.Empty;
                    for (int i = 0; i < UserDetails.Leads.Count; i++)
                    {
                        strLeadEmail += UserDetails.Leads[i].Lead_Email + ",";
                    }
                    if (strLeadEmail != string.Empty)
                    {
                        strLeadEmail = strLeadEmail.Substring(0, strLeadEmail.Length - 1);
                    }
                    objEmailclass.SendMailMessage(strLeadEmail, null, "Test", "Testing");
                }
                else
                {
                    string strAdminEmail = string.Empty;
                    strAdminEmail = UserDetails.Admin.Admin_Email_Id;
                    objEmailclass.SendMailMessage(strAdminEmail, null, "Test", "Testing");
                }
 
                if (rcbxType.Text == "Swipe Error")
                {
                    objAttendenceEntities.LastChangedUserId = UserDetails.User.EmployeeId;
                    objAttendenceDAO.UpdateAttendenceDetails(objAttendenceEntities);
                }
 
                LoadAttendenceGrid(true);
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Click Event By Admin or Leads to Approve the Status of a Particular Date Attendence of a Employee.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rbApprove_Click(object sender, EventArgs e)
        {
            try
            {
                objAttendenceEntities.MSIId = Session["MSIId"].ToString();
                objAttendenceEntities.AttDate = Convert.ToDateTime(Session["Date"]);
                objAttendenceEntities.LastChangedUserId = UserDetails.User.EmployeeId;
                objAttendenceDAO.UpdateAttendenceIsApproved(objAttendenceEntities);
 
                string strUserEmailId;
                CommonDAO objCommonDao = new CommonDAO();
                DataSet dsUserDetails = objCommonDao.GetUserDetails(Session["MSIId"].ToString());
                if (dsUserDetails != null)
                {
                    if (dsUserDetails.Tables.Count > 0)
                    {
                        if (dsUserDetails.Tables[0].Rows.Count > 0)
                        {
                            strUserEmailId = (string)dsUserDetails.Tables[0].Rows[0]["Email_Id"];
                            objEmailclass.SendMailMessage(strUserEmailId, null, "Test", "Approved");
                        }
                    }
                }
 
                LoadAttendenceGrid(true);
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Click Event By Admin or Leads to Reject the Status of a Particular Date Attendence of a Employee.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rbReject_Click(object sender, EventArgs e)
        {
            try
            {
                objAttendenceEntities.MSIId = Session["MSIId"].ToString();
                objAttendenceEntities.AttDate = Convert.ToDateTime(Session["Date"]);
                objAttendenceEntities.LastChangedUserId = UserDetails.User.EmployeeId;
                objAttendenceDAO.UpdateAttendenceIsApproved(objAttendenceEntities);
 
                string strUserEmailId;
                CommonDAO objCommonDao = new CommonDAO();
                DataSet dsUserDetails = objCommonDao.GetUserDetails(Session["MSIId"].ToString());
                if (dsUserDetails != null)
                {
                    if (dsUserDetails.Tables.Count > 0)
                    {
                        if (dsUserDetails.Tables[0].Rows.Count > 0)
                        {
                            strUserEmailId = (string)dsUserDetails.Tables[0].Rows[0]["Email_Id"];
                            objEmailclass.SendMailMessage(strUserEmailId, null, "Test", "Rejected");
                        }
                    }
                }
 
                LoadAttendenceGrid(true);
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        protected void rgMyAttendenceDetails_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            try
            {
                rgMyAttendenceDetails.DataSource = new int[] { };
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
 
        #endregion
 
        #region Methods
        /// <summary>
        /// Method to Load the Attendence Details Grid for a Select no of Employees.
        /// </summary>
        /// <param name="forceLoad"></param>
        private void LoadAttendenceGrid(bool forceLoad)
        {
            try
            {
                strEmployeeId = GetSelectedEmployees();
                objAttendenceDetailsEntities = new AttendenceDetailsEntities();
                rgAttendenceDetails.Columns.Clear();
                lblFromdatewithyear.Text = rdpFrom.SelectedDate.Value.Date.ToShortDateString();
                lblTodatewithyear.Text = rdpFrom.SelectedDate.Value.AddMonths(1).AddDays(-1).Date.ToShortDateString();
                if (Session["HomePage"] != null)
                {
                    if (Session["HomePage"].ToString() == "Home")
                    {
                        objAttendenceDetailsEntities.EmployeeId = UserDetails.User.MSIId;
                    }
                }
 
                else if (strEmployeeId != string.Empty)
                {
                    objAttendenceDetailsEntities.EmployeeId = strEmployeeId;
                }
                if (objAttendenceDetailsEntities.EmployeeId != null)
                {
 
                    objAttendenceDetailsEntities.FromDate = Convert.ToDateTime(rdpFrom.SelectedDate);
                    objAttendenceDetailsEntities.ToDate = Convert.ToDateTime(rdpFrom.SelectedDate.Value.AddMonths(1).AddDays(-1));
 
                    string[] strEmplId = objAttendenceDetailsEntities.EmployeeId.Split(',');
 
                    DataTable dtEmplyees = new DataTable();
 
                    //If it needs to be loaded again from database
                    if (forceLoad == true)
                    {
                        Session["AttData"] = objAttendenceDetailsDAO.GetFullAttendenceDetails(objAttendenceDetailsEntities);
                    }
 
                    dtEmplyees = (DataTable)Session["AttData"];
                    if (dtEmplyees != null)
                    {
                        dtEmplyees.DefaultView.Sort = "Att_Date";
                    }
                    rgAttendenceDetails.AutoGenerateColumns = false;
                    rgAttendenceDetails.MasterTableView.AutoGenerateColumns = false;
 
                    DataTable dtAttendence = new DataTable();
                    DataColumn dc = new DataColumn();
                    DataColumn dcCol2 = new DataColumn();
                    GridBoundColumn boundColumn = new GridBoundColumn();
 
                    GridTemplateColumn clNew;
 
                    for (int iLength = 0; iLength < strEmplId.Length; iLength++)
                    {
                        DataRow[] dr = dtEmplyees.Select("Emp_ID='" + strEmplId[iLength] + "'", "Att_Date");
 
                        if (dr.Length > 0)
                        {
 
                            DataRow drRow = dtAttendence.NewRow();
 
                            if (dr.Length + 1 != dtAttendence.Columns.Count)
                            {
                                boundColumn = new GridBoundColumn();
                                boundColumn.HeaderText = "Employee Id";
                                boundColumn.DataField = "Emp_ID";
                                boundColumn.UniqueName = "Emp_ID";
                                dc.ColumnName = "Emp_ID";
                                dtAttendence.Columns.Add(dc);
                                rgAttendenceDetails.MasterTableView.Columns.Add(boundColumn);
                            }
 
                            //To bind EmployeeId without 0 as the first Character.
                            if (strEmplId[iLength].StartsWith("0"))
                            {
                                drRow[dc.ColumnName] = strEmplId[iLength].Substring(1);
                            }
                            else
                            {
                                drRow[dc.ColumnName] = strEmplId[iLength];
                            }
                            for (int i = 0; i < dr.Length; i++)
                            {
                                if (dr.Length + 1 != dtAttendence.Columns.Count)
                                {
                                    dcCol2 = new DataColumn();
                                    dtAttendence.Columns.Add(dcCol2);
                                    dcCol2.ColumnName = dr[i]["Att_Date"].ToString();
                                }
 
                                //AttendenceDetailsDAO.AttendenceType objAttendanceType = (AttendenceDetailsDAO.AttendenceType)Enum.Parse(typeof(AttendenceDetailsDAO.AttendenceType), dr[i]["Status"].ToString());
                                AttendenceDetailsDAO.AttendenceType objAttendanceType = AttendenceDetailsDAO.GetValueFromDescription(dr[i]["Status"].ToString());
 
                                clNew = new GridTemplateColumn();
                                clNew.HeaderText = dr[i]["Day"].ToString();
                                string strcolName = dcCol2.ColumnName;
                                clNew.ItemTemplate = new MyTemplate(strcolName, ListItemType.Item, dr[i]["Att_Date"].ToString());
                                clNew.UniqueName = dcCol2.ColumnName;
                                clNew.DataField = dcCol2.ColumnName;
                                clNew.ItemStyle.ForeColor = Color.Blue;
 
                                if (dr.Length != rgAttendenceDetails.Columns.Count - 1)
                                {
                                    rgAttendenceDetails.MasterTableView.Columns.Add(clNew);
                                }
                                drRow[dr[i]["Att_Date"].ToString()] = AttendenceDetailsDAO.GetEnumDescription(objAttendanceType);
 
                            }
                            dtAttendence.Rows.Add(drRow);
                        }
                    }
                    //If there is no rows then
                    if (dtAttendence.Rows.Count > 0)
                    {
                        rgAttendenceDetails.DataSource = dtAttendence;
                        rgAttendenceDetails.DataBind();
                        rgAttendenceDetails.Visible = true;
                    }
                }
                else
                {
                    rgAttendenceDetails.DataSource = new int[] { };
                    rgAttendenceDetails.DataBind();
                    rgAttendenceDetails.Visible = false;
                }
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Method to Select Employees from the Employee RadCombobox.
        /// </summary>
        /// <returns></returns>
        private string GetSelectedEmployees()
        {
 
            try
            {
                string EmpIds = string.Empty;
 
                foreach (RadComboBoxItem item in rcbxEmployee.CheckedItems)
                {
                    EmpIds += item.Text + ",";
 
                }
                if (EmpIds != string.Empty)
                {
                    EmpIds = EmpIds.Substring(0, EmpIds.Length - 1);
                }
 
                return EmpIds;
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Method To Load Type into RadCombobox from DB Present in the AttendenceDetailsPopup.
        /// </summary>
        private void LoadRadCmboxType()
        {
            try
            {
                dsDetails = objAttendenceDetailsDAO.GetTypes();
                rcbxType.DataSource = dsDetails;
                foreach (DataRow dr in dsDetails.Tables[0].Rows)
                {
                    rcbxType.DataTextField = "TypeName";
                    rcbxType.DataValueField = "TypeId";
                }
                rcbxType.DataBind();
                rcbxType.Items.Insert(0, new RadComboBoxItem(string.Empty));//Adding a Empty Item to the dropdown.
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
 
        /// <summary>
        /// Method To Load The MyAttendenceDetails grid Present in the AttendenceDetailsPopup.
        /// </summary>
        private void LoadAttendenceGridPopUp()
        {
            try
            {
 
                DataSet AttdataSet = new DataSet();
                AttdataSet = objAttendenceDetailsDAO.GetAttPunchedInandOutDtls(objAttendenceDetailsEntities);
                DataTable dtAttendence = new DataTable();
                DataRow drAttendence = null;
 
                dtAttendence.Columns.Add("PunchIn", typeof(string));
                dtAttendence.Columns.Add("PunchOut", typeof(string));
                dtAttendence.Columns.Add("PunchIn2", typeof(string));
                dtAttendence.Columns.Add("PunchOut2", typeof(string));
                dtAttendence.Columns.Add("PunchIn3", typeof(string));
                dtAttendence.Columns.Add("PunchOut3", typeof(string));
                dtAttendence.Columns.Add("PunchIn4", typeof(string));
                dtAttendence.Columns.Add("PunchOut4", typeof(string));
 
                drAttendence = dtAttendence.NewRow();
                if (AttdataSet != null && AttdataSet.Tables.Count > 0 && AttdataSet.Tables[0].Rows.Count > 0)
                {
 
                    if (AttdataSet.Tables[0].Rows.Count > 0)
                    {
                        drAttendence["PunchIn"] = AttdataSet.Tables[0].Rows[0]["Punch_In"].ToString().Remove(5);
                        drAttendence["PunchOut"] = AttdataSet.Tables[0].Rows[0]["Punch_Out"].ToString().Remove(5);
                    }
                    else if (AttdataSet.Tables[0].Rows.Count > 1)
                    {
                        drAttendence["PunchIn2"] = AttdataSet.Tables[0].Rows[1]["Punch_In"].ToString().Remove(5);
                        drAttendence["PunchOut2"] = AttdataSet.Tables[0].Rows[1]["Punch_Out"].ToString().Remove(5);
                    }
                    else if (AttdataSet.Tables[0].Rows.Count > 2)
                    {
                        drAttendence["PunchIn3"] = AttdataSet.Tables[0].Rows[2]["Punch_In"].ToString().Remove(5);
                        drAttendence["PunchOut3"] = AttdataSet.Tables[0].Rows[2]["Punch_Out"].ToString().Remove(5);
                    }
                    else if (AttdataSet.Tables[0].Rows.Count > 3)
                    {
                        drAttendence["PunchIn4"] = AttdataSet.Tables[0].Rows[3]["Punch_In"].ToString().Remove(5);
                        drAttendence["PunchOut4"] = AttdataSet.Tables[0].Rows[3]["Punch_Out"].ToString().Remove(5);
                    }
                    dtAttendence.Rows.Add(drAttendence);
                }
                if (dtAttendence.Rows.Count > 0)
                {
                    rgMyAttendenceDetails.DataSource = dtAttendence;
                    rgMyAttendenceDetails.DataBind();
                }
                else
                {
                    rgMyAttendenceDetails.DataSource = new int[] { };
                    rgMyAttendenceDetails.DataBind();
                }
                LoadRadCmboxType();
            }
            catch (Exception ex)
            {
                objLogging.WriteToErrorLog(ex.Message);
                throw ex;
            }
        }
        #endregion
 
        #region Template Declarations
        /// <summary>
        /// RadGrid Template Class
        /// </summary>
        private class MyTemplate : ITemplate, IBindableTemplate
        {
            protected LinkButton lnkButton;
            protected LiteralControl lControl;
            private string colname;
            private ListItemType lstItemType;
            private string controlId;
            private string literalId;
            private string lnkbuttonId;
            private string commandArgument;
            public MyTemplate(string CName, ListItemType type, string commandArgument)
            {
                this.colname = CName;
                this.lstItemType = type;
                literalId = "lbl_" + type.ToString() + "_" + CName;
                lnkbuttonId = "lnk_" + type.ToString() + "_" + CName;
                this.commandArgument = commandArgument;
            }
 
            public void InstantiateIn(System.Web.UI.Control container)
            {
                switch (lstItemType)
                {
                    case ListItemType.Item:
 
                        lnkButton = new LinkButton();
                        controlId = "lnk_" + colname;
                        lnkButton.ID = controlId;
                        lnkButton.CommandName = "AttendenceCheck";
                        lnkButton.CommandArgument = commandArgument;
                        lnkButton.DataBinding += new EventHandler(lnkButton_DataBinding);
                        // lnkButton.Click += new EventHandler(lnkButton_Click);
                        container.Controls.Add(lnkButton);
 
                        lControl = new LiteralControl();
                        controlId = "lbl_" + colname;
                        lControl.ID = controlId;
                        lControl.DataBinding += new EventHandler(lControl_DataBinding);
                        container.Controls.Add(lControl);
 
                        break;
                }
            }
 
            public void lnkButton_DataBinding(object sender, EventArgs e)
            {
                LinkButton lnk = (LinkButton)sender;
                GridDataItem container = (GridDataItem)lnk.NamingContainer;
                lnk.Text = ((DataRowView)container.DataItem)[colname].ToString();
            }
 
            public void lControl_DataBinding(object sender, EventArgs e)
            {
                LiteralControl ltlControl = (LiteralControl)sender;
                GridDataItem container = (GridDataItem)ltlControl.NamingContainer;
                ltlControl.Text = ((DataRowView)container.DataItem)[colname].ToString();
            }
 
            public System.Collections.Specialized.IOrderedDictionary ExtractValues(System.Web.UI.Control container)
            {
                OrderedDictionary od = new OrderedDictionary();
 
                od.Add("ProviderName", ((LinkButton)((GridDataItem)container).FindControl(controlId)).Text);
 
                return od;
            }
        }
        #endregion
    }
}

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AttendenceDetails.ascx.cs"
    Inherits="AttendenceManagement.Controls.AttendenceDetailsGrid" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<link href="../CSS/AttendenceStyle.css" rel="stylesheet" type="text/css" />
<link href="../CSS/TelerikCustomSkins/Grid.css" rel="stylesheet" type="text/css" />
 
<script language="javascript" type="text/javascript">
 
    //    function getRadWindow() {
    //        var oWindow = null;
    //        if (window.radWindow) oWindow = window.radWindow;
    //        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
    //        return oWindow;
    //    }
 
    //    function closeWindow() {
    //        getRadWindow().close();
    //    }
 
    function OnClientClicked(sender, args) {
        var window = $find('<%=rwdAttendenceDetails.ClientID %>');
        window.close();
    }
          
</script>
 
<telerik:RadWindowManager ID="rwmAttendenceDetails" runat="server" ShowContentDuringLoad="false"
    VisibleStatusbar="false" Modal="true" VisibleTitlebar="false" EnableViewState="false"
    EnableEmbeddedSkins="false">
    <Windows>
        <telerik:RadWindow ID="rwdAttendenceDetails" runat="server" ShowContentDuringLoad="true"
            VisibleStatusbar="false" Modal="true" VisibleTitlebar="false" VisibleOnPageLoad="false"
            BorderWidth="0" BorderStyle="None" Height="400px" Width="700px">
            <ContentTemplate>
                <div style="width: 676px; height: 376px; background-color: #323367; vertical-align: top;
                    margin-top: 0px !important; border: 4px solid skyblue;">
                    <div class="divClose">
                        <telerik:RadButton ID="rbClose" runat="server" Height="17px" Width="20px" AutoPostBack="false"
                            OnClientClicked="OnClientClicked">
                        </telerik:RadButton>
                    </div>
                    <div class="divlblAttendenceDetails">
                        <asp:Label ID="lblAttendenceDetails" runat="server" Text="My Attendence Details"
                            ForeColor="White"></asp:Label>
                    </div>
                    <div class="divEmplyeeDetail">
                        <asp:Label ID="lblEmployeeName" runat="server" Text="Employee Name :" ForeColor="White"></asp:Label>
                        <asp:Label ID="lblEmployeeNameValue" runat="server" CssClass="rtxtEmployeeNameStyle"
                            ForeColor="White">
                        </asp:Label>
                        <asp:Label ID="lblEmployeeId" runat="server" Text="Empolyee Id :" CssClass="lblEmployeeIdStyle"
                            ForeColor="White"></asp:Label>
                        <asp:Label ID="lblEmployeeIdValue" runat="server" CssClass="lblEmployeeIdValueStyle"
                            ForeColor="White"></asp:Label>
                        <asp:Label ID="lblDate" runat="server" Text="Date :" CssClass="lblDateStyle" ForeColor="White"></asp:Label>
                        <asp:Label ID="lblDateValue" runat="server" CssClass="rtbxDateStyle" ForeColor="White">
                        </asp:Label>
                    </div>
                    <div class="divGrid">
                        <telerik:RadGrid ID="rgMyAttendenceDetails" runat="server" GridLines="None" AutoGenerateColumns="false"
                            ShowHeader="true" ShowFooter="true" EnableEmbeddedSkins="false" OnNeedDataSource="rgMyAttendenceDetails_NeedDataSource"
                            Skin="Internal" CssClass="RadGridStyle">
                            <HeaderStyle VerticalAlign="Middle" HorizontalAlign="Center" CssClass="RadGridStyle" />
                            <MasterTableView AutoGenerateColumns="false" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true"
                                ShowHeader="true" ShowFooter="true" CssClass="RadGridStyle">
                                <Columns>
                                    <telerik:GridBoundColumn HeaderText="PunchIn" DataField="PunchIn">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PunchOut" DataField="PunchOut">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PunchIn2" DataField="PunchIn2">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PunchOut2" DataField="PunchOut2">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PunchIn3" DataField="PunchIn3">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PunchOut3" DataField="PunchOut3">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PunchIn4" DataField="PunchIn4">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PunchOut4" DataField="PunchOut4">
                                    </telerik:GridBoundColumn>
                                </Columns>
                                <NoRecordsTemplate>
                                    <div>
                                        <asp:Literal ID="ltlNoRecords" runat="server" Text="No Swipe Details Available"></asp:Literal>
                                    </div>
                                </NoRecordsTemplate>
                            </MasterTableView>
                        </telerik:RadGrid></div>
                    <asp:Label ID="lblDetails" runat="server" Visible="True"></asp:Label>
                    <div class="divComments">
                        <asp:Label ID="lblComments" runat="server" Text="Comments" Visible="true" ForeColor="White"></asp:Label>
                        <telerik:RadTextBox ID="rtbxComments" runat="server" Width="350px" Height="50px"
                            TextMode="MultiLine" MaxLength="300" CssClass="rtbxCommentsStyle" Visible="true">
                        </telerik:RadTextBox>
                    </div>
                    <div class="divType">
                        <asp:Label ID="lblType" runat="server" Text="Type" Visible="true" ForeColor="White"></asp:Label>
                        <telerik:RadComboBox ID="rcbxType" runat="server" CssClass="rcbxTypeStyle" Visible="true"
                            AutoPostBack="false" Width="125px">
                        </telerik:RadComboBox>
                    </div>
                    <asp:Panel ID="pnlOkCancel" runat="server" Visible="false" Style="float: left;">
                        <div class="divbtn">
                            <asp:Button ID="rbOk" runat="server" Text="Ok" Width="75px" OnClick="rbOk_Click">
                            </asp:Button>
                            <asp:Button ID="rbCancel" runat="server" Text="Cancel" Width="75px" OnClientClick="OnClientClicked();return false;">
                            </asp:Button>
                        </div>
                    </asp:Panel>
                    <asp:Panel ID="pnlAcceptReject" Visible="false" runat="server">
                        <div class="divbtn">
                            <asp:Button ID="rbApprove" runat="server" Text="Approve" Width="75px" OnClick="rbApprove_Click">
                            </asp:Button>
                            <asp:Button ID="rbReject" runat="server" Text="Reject" Width="75px" OnClick="rbReject_Click">
                            </asp:Button>
                        </div>
                    </asp:Panel>
                </div>
            </ContentTemplate>
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<div class="divlblHeader">
    <asp:Label ID="lblHeader" runat="server" Text="Attendence Details"></asp:Label></div>
<asp:Panel runat="server" ID="pnlout" BackColor="#D8D8D8" Height="80px">
    <div class="divPickerLabel">
        <div class="divPicker">
            <div class="divFromDate">
                <asp:Label ID="lblFromDate" runat="server" Text="From"></asp:Label>
                <telerik:RadDatePicker ID="rdpFrom" runat="server" CssClass="rtxtFromStyle" Width="125px">
                </telerik:RadDatePicker>
            </div>
            <asp:Panel ID="pnlEmployee" runat="server" Style="float: left;">
                <div class="divSelectEmployee">
                    <asp:Label ID="lblSelectEmployee" runat="server" Text="Select Employee"></asp:Label>
                    <telerik:RadComboBox ID="rcbxEmployee" runat="server" CssClass="rcbxEmployeeStyle"
                        Visible="true" Width="125px" CheckBoxes="true" EnableCheckAllItemsCheckBox="true">
                    </telerik:RadComboBox>
                </div>
            </asp:Panel>
            <div class="divbtnSelect">
                <asp:Button ID="rbtnSelect" runat="server" Text="Select" OnClick="rbtnSelect_Click"
                    CssClass="rbtnSelectStyle" Width="75px"></asp:Button>
            </div>
        </div>
    </div>
    <div class="divfromdatetodatelbl">
        <div class="divlblfromdatetodate">
            <div class="divDummy">
            </div>
            <asp:Label ID="lblAttendenceDetaisFrom" runat="server" Text="Attendence Details From"></asp:Label>
            <asp:Label ID="lblFromdatewithyear" runat="server"></asp:Label>
            <asp:Label ID="lblTo" runat="server" Text="To"></asp:Label>
            <asp:Label ID="lblTodatewithyear" runat="server"></asp:Label></div>
    </div>
</asp:Panel>
<div class="divlegend">
    <asp:Panel ID="pnllegend" runat="server" BackColor="Gray" Height="95px">
        <table runat="server" cellpadding="0" cellspacing="0">
            <tr>
                <td style="width: 11%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: White; height: 20px; text-align: center; width: 20px;
                        float: left;">
                        <span>P</span>
                    </div>
                    <div>
                        <asp:Label ID="lblPresent" runat="server" Text="Present" CssClass="lblLegendStyle"
                            ForeColor="White"></asp:Label></div>
                </td>
                <td style="width: 12%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Red; height: 20px; text-align: center; width: 20px;
                        float: left;">
                        <span>A</span>
                    </div>
                    <div>
                        <asp:Label ID="lblAbsent" runat="server" Text="Absent" CssClass="lblLegendStyle"
                            ForeColor="White"></asp:Label></div>
                </td>
                <td style="width: 14%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: PowderBlue; height: 20px; text-align: center; width: 20px;
                        float: left;">
                        <span>H</span>
                    </div>
                    <div>
                        <asp:Label ID="lblHoilday" runat="server" Text="Holiday" CssClass="lblLegendStyle"
                            ForeColor="White"></asp:Label></div>
                </td>
                <td style="width: 20%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Plum; height: 20px; text-align: center; width: 25px;
                        float: left;">
                        <span>RH</span>
                    </div>
                    <div>
                        <asp:Label ID="lblResHoliday" runat="server" Text="Restricted Holiday" CssClass="lblLegendStyle"
                            ForeColor="White">
                        </asp:Label></div>
                </td>
                <td style="width: 19%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Aquamarine; height: 20px; text-align: center; width: 25px;
                        float: left;">
                        <span>HL</span>
                    </div>
                    <div>
                        <asp:Label ID="lblHDLeave" runat="server" Text="Half Day Leave" CssClass="lblLegendStyle"
                            ForeColor="White">
                        </asp:Label></div>
                </td>
                <td colspan="2" style="width: 100%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Aqua; height: 20px; text-align: center; width: 25px;
                        float: left;">
                        <span>SR</span>
                    </div>
                    <div>
                        <asp:Label ID="lblSwipeError" runat="server" Text="Swipe Error" CssClass="lblLegendStyle"
                            ForeColor="White">
                        </asp:Label></div>
                </td>
            </tr>
            <tr>
                <td style="width: 10%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Blue; height: 20px; text-align: center; width: 20px;
                        float: left;">
                        <span>L</span>
                    </div>
                    <div>
                        <asp:Label ID="lblLeave" runat="server" Text="Leave" CssClass="lblLegendStyle" ForeColor="White"></asp:Label></div>
                </td>
                <td style="width: 12%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Peru; height: 20px; text-align: center; width: 20px;
                        float: left;">
                        <span>C</span>
                    </div>
                    <div>
                        <asp:Label ID="lblCompoff" runat="server" Text="CompOff" CssClass="lblLegendStyle"
                            ForeColor="White"></asp:Label></div>
                </td>
                <td style="width: 15%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Green; height: 20px; text-align: center; width: 20px;
                        float: left;">
                        <span>T</span>
                    </div>
                    <div>
                        <asp:Label ID="lblTemporaryId" runat="server" Text="TemporaryId" CssClass="lblLegendStyle"
                            ForeColor="White">
                        </asp:Label></div>
                </td>
                <td style="width: 20%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Yellow; height: 20px; text-align: center; width: 26px;
                        float: left;">
                        <span>WH</span>
                    </div>
                    <div>
                        <asp:Label ID="lblWorkFromHome" runat="server" Text="Work From Home" CssClass="lblLegendStyle"
                            ForeColor="White">
                        </asp:Label></div>
                </td>
                <td style="width: 19%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Tan; height: 20px; text-align: center; width: 25px;
                        float: left;">
                        <span>HA</span>
                    </div>
                    <div>
                        <asp:Label ID="lblHDAbsent" runat="server" Text="Half Day Absent" CssClass="lblLegendStyle"
                            ForeColor="White">
                        </asp:Label></div>
                </td>
                <td colspan="2" style="width: 100%; padding: 15px 0px 0px 20px;">
                    <div style="background-color: Fuchsia; height: 20px; text-align: center; width: 25px;
                        float: left;">
                        <span>AP</span>
                    </div>
                    <div>
                        <asp:Label ID="lblApproval" runat="server" Text="Approval Needed" CssClass="lblLegendStyle"
                            ForeColor="White">
                        </asp:Label></div>
                </td>
            </tr>
        </table>
    </asp:Panel>
</div>
<div class="divrGrid">
    <telerik:RadGrid ID="rgAttendenceDetails" runat="server" AllowSorting="true" AllowPaging="true"
        PagerStyle-ShowPagerText="true" PagerStyle-AlwaysVisible="true" AutoGenerateColumns="false"
        SortingSettings-EnableSkinSortStyles="false" EnableEmbeddedSkins="false" CellSpacing="0"
        Skin="Internal" GridLines="Both" CssClass="rgLeaveApproval" OnItemCommand="rgAttendenceDetails_ItemCommand"
        OnItemDataBound="rgAttendenceDetails_ItemDataBound" >
        <MasterTableView AutoGenerateColumns="false" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true"
            ShowHeader="true" ShowFooter="true">
            <HeaderStyle VerticalAlign="Middle" HorizontalAlign="Center" />
            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
            <NoRecordsTemplate>
                <div>
                    <asp:Literal ID="ltlNoRecords" runat="server" Text="No Records To Display"></asp:Literal>
                </div>
            </NoRecordsTemplate>
        </MasterTableView>
    </telerik:RadGrid>
</div>


Antonio Stoilkov
Telerik team
 answered on 28 Nov 2012
1 answer
243 views
Hello everyone, 

I'm very new to telerik controls, ajax and asp.net. And I have been stacked with this for several days. 
I'm having a problem with Master Page and Partial Postback from UserControls.
My objective is to show alert to user one minute before session was expired by redirecting to prepared page..
I implemented it by Refreshing Warning page with desired time interval.
I added following line at Page_Load event of MasterPage to refresh and show warning one minute before timeout.

Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 60) + ";URL=ExtendSession.aspx");

This is AjaxManager Manager Code block from MasterPage.
<telerik:RadAjaxManager ID="ajaxManager" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="cboShortCut">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="cboShortCut" UpdatePanelRenderMode="Inline" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

At ExtendSession.aspx, I used javascript to show countdown timer and ask user to Extend or Logout.
Everything works fine if I open new aspx page, timer was reset.
But it was not reset when something was changed from UserControl inside aspx pages.
Example, OnSelectedIndexChange event of RadComboBox does not reset the timer.
This is part of markup page for RadComboBox from UserControl.
<telerik:RadAjaxManagerProxy ID="ajaxmanagerproxy" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="cboTest">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="cboSubTest" UpdatePanelRenderMode="Inline" />
                <telerik:AjaxUpdatedControl ControlID="cboSubTest2" UpdatePanelRenderMode="Inline" />
                <telerik:AjaxUpdatedControl ControlID="lblValue" UpdatePanelRenderMode="Inline" />
            </UpdatedControls>
        </telerik:AjaxSetting>
     </AjaxSettings>
</telerik:RadAjaxManagerProxy>
<telerik:AjaxSetting AjaxControlID="ajaxManager">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="uploadAssetImg" UpdatePanelRenderMode="Inline" />
                <telerik:AjaxUpdatedControl ControlID="cboTest" UpdatePanelRenderMode="Inline" />
                <telerik:AjaxUpdatedControl ControlID="cboOthers" UpdatePanelRenderMode="Inline" />
            </UpdateControls>
</telerik:AjaxSetting>

...

<telerik:RadComboBox ID="cboTest" runat="server" AutoPostBack="true" OnSelectedIndexChanged="cboTest_SelectedIndexChanged" />

I tried to change PageHeader of MasterPage by adding following line at LoadEvent from BaseClass of UserControls.

protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (this.Page.Master.AppRelativeVirtualPath == "~/MasterPage.Master")
            {
                Page l_CurrentPage = HttpContext.Current.CurrentHandler as Page;
                MasterPage l_MasterPage = (MasterPage)l_CurrentPage.Master;
                l_MasterPage.Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) - 60) + ";URL=ExtendSession.aspx");
            }
        }

But unfortunately, MasterPage was not reset and ended with following error message with its time's up :(

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 
Requested URL: /ExtendSession.aspx, 60;URL=ExtendSession.aspx

Please help guys.
I think this is partial postback. Is there a way to handle partial postback at MasterPage?
Is my approach is incorrect? Or is there any way to change PageHeader of MasterPage from UserControl?
Or is there any setting at RadAjaxManager to handle partial postback?

Please let me know if my provided information are not enough.
Thanks in advanced.
Thant Sin Lin
Robin
Top achievements
Rank 2
 answered on 28 Nov 2012
5 answers
119 views
hey friends,


    i want to delete in radgrid without using sqldatasource i telerik gridtemplatecolumn
 <telerik:GridTemplateColumn UniqueName="TemlateDeletecolumn" AllowFiltering="false">
                            <ItemTemplate>
                            <asp:HyperLink ID="DeleteLink" runat="server"  ImageUrl="Delete.gif"></asp:HyperLink>
                            </ItemTemplate>
                            
                            </telerik:GridTemplateColumn>

how can i do this?
Princy
Top achievements
Rank 2
 answered on 28 Nov 2012
2 answers
87 views
Hi,

I'm having trouble having the grid filtered when it loads. My query lists all users, but I want it to only show users where IsActive = True, which is a checkbox. I used the example here as my template and it seems pretty straightforward. (The last example on the page pertains to checkboxes.)

According to the example, I added
CurrentFilterFunction="EqualTo" CurrentFilterValue="True"
to the checkbox column and it was just fine.

When I add
FilterExpression="([IsActive] = True)"
the grid fails to load and gives me a ParseException error (either "expected expression" with brackets around IsActive, or "No property or field 'IsActive' exists in type 'DataRowView'" without the brackets.

Thanks in advance!

Here is the grid & data source:
<telerik:RadGrid ID="grd_UserAdmin" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
    AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" ShowGroupPanel="True"
    Skin="Black" AllowAutomaticInserts="True" ShowFooter="True" DataSourceID="ds_UserAdmin">
    <ClientSettings AllowColumnsReorder="True" AllowDragToGroup="True" ReorderColumnsOnClient="True"
        AllowKeyboardNavigation="True" ColumnsReorderMethod="Reorder">
    </ClientSettings>
    <MasterTableView AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" DataKeyNames="UserName"
        EditMode="PopUp" DataSourceID="ds_UserAdmin" FilterExpression="([IsActive] = True)">
        <Columns>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                <ItemStyle CssClass="MyImageButton" />
            </telerik:GridEditCommandColumn>
            <telerik:GridButtonColumn ConfirmText="Delete this user?" ConfirmDialogType="RadWindow"
                ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                UniqueName="clmDeleteColumn" FilterControlAltText="Filter clmDeleteColumn column">
                <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn DataField="FirstName" FilterControlAltText="Filter FirstName column"
                HeaderText="First Name" SortExpression="FirstName" UniqueName="clmFirstName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LastName" FilterControlAltText="Filter clmLastName column"
                HeaderText="Last Name" SortExpression="LastName" UniqueName="clmLastName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="UserName" FilterControlAltText="Filter clmUserName column"
                HeaderText="User Name" SortExpression="UserName" UniqueName="clmUserName">
            </telerik:GridBoundColumn>
            <telerik:GridCheckBoxColumn DataField="IsActive" DataType="System.Boolean" FilterControlAltText="Filter clmIsActive column"
                HeaderText="Is Active?" SortExpression="IsActive" UniqueName="clmIsActive" EditFormColumnIndex="1"
                CurrentFilterFunction="EqualTo" CurrentFilterValue="True">
            </telerik:GridCheckBoxColumn>
            <telerik:GridBoundColumn DataField="LastActivityDate" DataType="System.DateTime" FilterControlAltText="Filter clmLastActivityDate column"
                HeaderText="Last Activity Date" SortExpression="LastActivityDate" UniqueName="clmLastActivityDate"
                EditFormColumnIndex="1" ReadOnly="True">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Email" FilterControlAltText="Filter Email column"
                HeaderText="E-Mail" SortExpression="Email" UniqueName="clmEmail" EditFormColumnIndex="1">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>
<telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px">
</telerik:GridDropDownListColumnEditor>
<asp:SqlDataSource ID="ds_UserAdmin" runat="server" ConnectionString="<%$ ConnectionStrings:Alderman_ConnectionString %>"
    SelectCommand="SELECT * FROM vw_Users"
    DeleteCommand="sp_web_UserAdministration_del" DeleteCommandType="StoredProcedure">
    <DeleteParameters>
        <asp:Parameter Name="UserID" Type="Object" />
    </DeleteParameters>
</asp:SqlDataSource>



Shinu
Top achievements
Rank 2
 answered on 28 Nov 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?