or
DataRow[] changedRows = this.UserDataSource.Select("user_id = " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Users"]);protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e){ GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); //Prepare new row to add it in the DataSource DataRow[] changedRows = this.UserDataSource.Select("user_id = " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Users"]);// in progress. to be implemented here}<%@ Page Title="" Language="C#" MasterPageFile="~/App_MasterPages/OneColumnMasterPage.Master" AutoEventWireup="true" CodeBehind="AddModifyType.aspx.cs" Inherits="Schedule.Administration.AddModifyType" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadPlaceHolder" runat="server"> <style type="text/css"> .EditFormHeader td { font-size: 14px; padding: 4px !important; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; color: #646882; text-decoration: none; font-weight: bold; height: 22px; border: 1 px; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <br /> <table cellpadding="3" cellspacing="0" border="0" style="width: 100%;"> <tr> <td id="header"> <SCHEDULE:uxPageTitle ID="uxPageTitle" Title="Add/Modify Type" runat="server"></SCHEDULE:uxPageTitle> <table border="0" cellpadding="0" cellspacing="0" width="100%" class="box"> <tr class="boxTop"> <td> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> </telerik:RadCodeBlock> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> <telerik:AjaxUpdatedControl ControlID="divMsgs" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"> </telerik:RadAjaxLoadingPanel> <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" /> <telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" AutoGenerateColumns="False" Skin="Windows7" AllowPaging="True" ShowStatusBar="True" OnPreRender="RadGrid1_PreRender" OnNeedDataSource="RadGrid1_NeedDataSource" OnUpdateCommand="RadGrid1_UpdateCommand" OnInsertCommand="RadGrid1_InsertCommand" OnDeleteCommand="RadGrid1_DeleteCommand" CellSpacing="0" GridLines="None" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound" onitemcommand="RadGrid1_ItemCommand"> <HeaderStyle Font-Bold="True" Font-Size="9pt"></HeaderStyle> <ItemStyle Font-Size="8.5pt" /> <AlternatingItemStyle Font-Size="8.5pt" /> <PagerStyle Mode="NextPrevAndNumeric" /> <ClientSettings> <Selecting AllowRowSelect="True"></Selecting> </ClientSettings> <ClientSettings> <Selecting CellSelectionMode="None" AllowRowSelect="True"></Selecting> </ClientSettings> <MasterTableView Width="100%" TableLayout="Auto" CommandItemDisplay="Top" DataKeyNames="Type"> <Columns> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" HeaderStyle-Width="24" EditImageUrl="../Skins/Outlook/Grid/Edit.gif"> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="Type" DataType="System.Int32" ItemStyle-Width="7px" HeaderText="Type" SortExpression="Type" UniqueName="Type"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="TypeDescription" ItemStyle-Width="220px" HeaderText="Description" SortExpression="TypeDescription" UniqueName="TypeDescription"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="MinLbsGVW" ItemStyle-Width="15px" HeaderText="Min Lbs GVW" SortExpression="MinLbsGVW" UniqueName="MinLbsGVW"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="MaxLbsGVW" ItemStyle-Width="15px" HeaderText="Max Lbs GVW" SortExpression="MaxLbsGVW" UniqueName="MaxLbsGVW"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ReportClassification" ItemStyle-Width="95px" HeaderText="Report Class" SortExpression="ReportClassification" UniqueName="ReportClassification"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="L_H_S" ItemStyle-Width="10px" HeaderText="L/H/S" SortExpression="L_H_S" UniqueName="L_H_S"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="RepModel" ItemStyle-Width="40px" HeaderText="Replacement Model" SortExpression="RepModel" UniqueName="RepModel"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="AmortizationClassification" HeaderText="Amortization Class" SortExpression="AmortizationClassification" ItemStyle-Width="60px" UniqueName="AmortizationClassification"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CountClass" ItemStyle-Width="10px" HeaderText="Count Class" SortExpression="CountClass" UniqueName="CountClass"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="RepCost" DataType="System.Decimal" ItemStyle-Width="60px" DataFormatString="{0:C}" HeaderText="Replacement Cost" SortExpression="RepCost" UniqueName="RepCost"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LeadTimeRequired" HeaderText="Lead Time" SortExpression="LeadTimeRequired" Visible="false" UniqueName="LeadTimeRequired"> </telerik:GridBoundColumn> <telerik:GridCheckBoxColumn DataField="HasTires" DataType="System.Boolean" ItemStyle-Width="10px" HeaderText="Tires" SortExpression="HasTires" UniqueName="HasTires"> </telerik:GridCheckBoxColumn> <telerik:GridCheckBoxColumn DataField="FirstAidKitRequired" DataType="System.Boolean" ItemStyle-Width="10px" HeaderText="First Aid" SortExpression="FirstAidKitRequired" UniqueName="FirstAidKitRequired"> </telerik:GridCheckBoxColumn> <telerik:GridBoundColumn DataField="FireExtinguisherSize" Visible="false" HeaderText="Fire Exting. Size" SortExpression="FireExtinguisherSize" UniqueName="FireExtinguisherSize"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CAMFM" ItemStyle-Width="17px" HeaderText="CAMFM" SortExpression="CAMFM" UniqueName="CAMFM"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EffectiveDate" DataType="System.DateTime" DataFormatString="{0:yyyy/MM/dd}" ItemStyle-Width="20px" HeaderText="Effective Date" SortExpression="EffectiveDate" Visible="false" UniqueName="EffectiveDate"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CreatorID" Visible="false" ReadOnly="true" HeaderText="CreatorID" SortExpression="CreatorID" UniqueName="CreatorID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LastModifyID" Visible="false" ReadOnly="true" HeaderText="Modify By" SortExpression="LastModifyID" UniqueName="LastModifyID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LastModifyTime" Visible="false" ReadOnly="true" DataType="System.DateTime" HeaderText="Modify Time" SortExpression="LastModifyTime" UniqueName="LastModifyTime"> </telerik:GridBoundColumn> <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this record?" ButtonType="ImageButton" ImageUrl="../Skins/Outlook/Grid/Delete.gif" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"> <HeaderStyle Width="20px" /> </telerik:GridButtonColumn> </Columns> <EditFormSettings UserControlName="~/Controls/Type/uxAddModifyType.ascx" EditFormType="WebUserControl"> <EditColumn UniqueName="EditCommandColumn1"> </EditColumn> </EditFormSettings> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> </telerik:RadGrid> <br /> <br /> <p id="divMsgs" runat="server"> <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080"></asp:Label> <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000"></asp:Label> </p> <br /> </td> </tr> </table> </td> </tr> </table> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="ModalPlaceHolder" runat="server"> </asp:Content> using System; using System.Linq; using System.Web.UI; using System.Web.UI.WebControls; using Telerik.Web.UI; using System.Data; using System.Collections; using System.Configuration; using System.Data.SqlClient; using System.Globalization; using System.Security.Principal; using Schedule.Helpers; namespace Schedule.Administration { public partial class AddModifyType : ScheduleBasePage { #region Data members #endregion protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { } } private static DataTable GetDataTable(string queryString) { String ConnString = ConfigurationManager.ConnectionStrings["MinotaurConnectionString"].ConnectionString; SqlConnection MySqlConnection = new SqlConnection(ConnString); SqlDataAdapter MySqlDataAdapter = new SqlDataAdapter(); MySqlDataAdapter.SelectCommand = new SqlCommand(queryString, MySqlConnection); DataTable myDataTable = new DataTable(); MySqlConnection.Open(); try { MySqlDataAdapter.Fill(myDataTable); } finally { MySqlConnection.Close(); } return myDataTable; } protected void RadGrid1_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { string ID = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Type"].ToString(); DataTable typeTable = this.SqlDataSourceTypesDataTable; try { if (typeTable.Rows.Find(ID) != null) { typeTable.Rows.Find(ID).Delete(); typeTable.AcceptChanges(); DisplayMessage(false, "Your Type has been deleted successfully!"); } } catch (Exception ex) { DisplayMessage(true, "Your Type could not be deleted. Reason: " + ex.Message); e.Canceled = true; } } private DataTable SqlDataSourceTypesDataTable { get { object obj = this.Session["ModifyTypes"]; if ((!(obj == null))) { return ((DataTable)(obj)); } DataTable myDataTable = new DataTable(); myDataTable = GetDataTable("SELECT Type, TypeDescription, MinLbsGVW, MaxLbsGVW, ReportClassification, [L/H/S], RepModel, AmortizationClassification, CountClass,RepCost, LeadTimeRequired, HasTires, FirstAidKitRequired, CAMFM, EffectiveDate, CreatorID, LastModifyID, LastModifyTime from Types"); this.Session["ModifyTypes"] = myDataTable; return myDataTable; } } protected void RadGrid1_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); int rowindex = editedItem.ItemIndex; //Row index to identify the row edited String selectQuery = String.Format("Type='{0}'", editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Type"]); DataRow[] changedRows = this.SqlDataSourceTypesDataTable.Select(selectQuery); if (changedRows.Length != 1) { RadGrid1.Controls.Add(new LiteralControl("Unable to locate the row for updating.")); e.Canceled = true; return; } string domainUser = null; WindowsIdentity userName = WindowsIdentity.GetCurrent(); if (userName != null) { domainUser = StringManipulation.ExtractUserName(userName.Name.ToString()); } //Update new values Hashtable newValues = new Hashtable(); newValues["Type"] = (userControl.FindControl("txtTypeNumber") as TextBox).Text; newValues["TypeDescription"] = (userControl.FindControl("txtTypeDescription") as TextBox).Text; newValues["MinLbsGVW"] = (userControl.FindControl("txtMinLbsGVW") as TextBox).Text; newValues["MaxLbsGVW"] = (userControl.FindControl("txtMaxLbsGVW") as TextBox).Text; newValues["ReportClassification"] = (userControl.FindControl("txtReportClassification") as TextBox).Text; newValues["L/H/S"] = (userControl.FindControl("txtLHS") as TextBox).Text; newValues["RepModel"] = (userControl.FindControl("txtReplacementModel") as TextBox).Text; newValues["AmortizationClassification"] = (userControl.FindControl("txtAmortization") as TextBox).Text; newValues["CountClass"] = (userControl.FindControl("txtCountClass") as TextBox).Text; newValues["RepCost"] = double.Parse(((userControl.FindControl("txtReplacementCost") as TextBox).Text), NumberStyles.Currency); newValues["LeadTimeRequired"] = 0; newValues["HasTires"] = (userControl.FindControl("chkHasTires") as CheckBox).Checked; newValues["FirstAidKitRequired"] = (userControl.FindControl("chkFirstAid") as CheckBox).Checked; newValues["CAMFM"] = (userControl.FindControl("txtCAMFM") as TextBox).Text; newValues["EffectiveDate"] = (userControl.FindControl("lblEffectiveDate") as Label).Text; newValues["CreatorID"] = (userControl.FindControl("lblEffectiveDate") as Label).Text; newValues["LastModifyID"] = domainUser;// (userControl.FindControl("lblModifiedBy") as Label).Text; newValues["LastModifyTime"] = DateTime.Now; changedRows[0].BeginEdit(); try { foreach (DictionaryEntry entry in newValues) { changedRows[0][(string)entry.Key] = entry.Value; } changedRows[0].EndEdit(); this.SqlDataSourceTypesDataTable.AcceptChanges(); DisplayMessage(false, "Your Type has been updated successfully!"); } catch (Exception ex) { changedRows[0].CancelEdit(); DisplayMessage(true, "Your Type could not be updated. Reason: " + ex.Message); e.Canceled = true; } } private void DisplayMessage(bool isError, string text) { Label label = (isError) ? this.Label1 : this.Label2; label.Text = text; } protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == RadGrid.PerformInsertCommandName) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); //Create new row in the DataSource DataRow newRow = this.SqlDataSourceTypesDataTable.NewRow(); string domainUser = null; WindowsIdentity userName = WindowsIdentity.GetCurrent(); if (userName != null) { domainUser = StringManipulation.ExtractUserName(userName.Name.ToString()); } //Insert new values Hashtable newValues = new Hashtable(); newValues["Type"] = (userControl.FindControl("txtTypeNumber") as TextBox).Text; newValues["TypeDescription"] = (userControl.FindControl("txtTypeDescription") as TextBox).Text; newValues["MinLbsGVW"] = (userControl.FindControl("txtMinLbsGVW") as TextBox).Text; newValues["MaxLbsGVW"] = (userControl.FindControl("txtMaxLbsGVW") as TextBox).Text; newValues["ReportClassification"] = (userControl.FindControl("txtReportClassification") as TextBox).Text; newValues["L/H/S"] = (userControl.FindControl("txtLHS") as TextBox).Text; newValues["RepModel"] = (userControl.FindControl("txtReplacementModel") as TextBox).Text; newValues["AmortizationClassification"] = (userControl.FindControl("txtAmortization") as TextBox).Text; newValues["CountClass"] = (userControl.FindControl("txtCountClass") as TextBox).Text; newValues["RepCost"] = double.Parse(((userControl.FindControl("txtReplacementCost") as TextBox).Text), NumberStyles.Currency); newValues["LeadTimeRequired"] = 0; newValues["HasTires"] = (userControl.FindControl("chkHasTires") as CheckBox).Checked; newValues["FirstAidKitRequired"] = (userControl.FindControl("chkFirstAid") as CheckBox).Checked; newValues["CAMFM"] = (userControl.FindControl("txtCAMFM") as TextBox).Text; newValues["EffectiveDate"] = (userControl.FindControl("lblEffectiveDate") as Label).Text; newValues["CreatorID"] = domainUser; // (userControl.FindControl("lblEffectiveDate") as Label).Text; newValues["LastModifyID"] = domainUser; // (userControl.FindControl("lblModifiedBy") as Label).Text; newValues["LastModifyTime"] = DateTime.Now; ////make sure that unique primary key value is generated for the inserted row // newValues["Type"] = (int)this.SqlDataSourceTypeDataTable.Rows[this.SqlDataSourceTypeDataTable.Rows.Count - 1]["Type"] + 1; try { foreach (DictionaryEntry entry in newValues) { newRow[(string)entry.Key] = entry.Value; } this.SqlDataSourceTypesDataTable.Rows.Add(newRow); this.SqlDataSourceTypesDataTable.AcceptChanges(); DisplayMessage(false, "Your Type has been inserted successfully!"); } catch (Exception ex) { DisplayMessage(true, "Your Type could not be inserted. Reason: " + ex.Message); e.Canceled = true; } } } protected void RadGrid1_PreRender(object sender, System.EventArgs e) { if (!this.IsPostBack) { this.RadGrid1.MasterTableView.Items[1].Edit = true; this.RadGrid1.MasterTableView.Rebind(); } } protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) { if (e.Column.IsBoundToFieldName("Date")) { (e.Column as GridDateTimeColumn).DataFormatString = "{0:D}"; } else if (e.Column.IsBoundToFieldName("UnitPrice")) { (e.Column as GridNumericColumn).DataFormatString = "{0:C}"; } if (e.Column is GridBoundColumn) { (e.Column as GridBoundColumn).FilterControlWidth = System.Web.UI.WebControls.Unit.Pixel(100); } } protected void RadGrid1_EditCommand(object sender, GridCommandEventArgs e) { } protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { this.RadGrid1.DataSource = this.SqlDataSourceTypesDataTable; this.SqlDataSourceTypesDataTable.PrimaryKey = new DataColumn[] { this.SqlDataSourceTypesDataTable.Columns["Type"] }; } protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { //if (e.Item is GridEditFormItem && e.Item.IsInEditMode) //{ // UserControl MyUserControl = e.Item.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl; // string script = String.Format("$get('{0}').focus(); $get('{0}').select();", MyUserControl.FindControl("TextBox7").ClientID); // ScriptManager.RegisterStartupScript(Page, typeof(Page), "myscript", script, true); //} } protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); TextBox dataField = (userControl.FindControl("txtTypeDescription") as TextBox); dataField.Focus(); } } protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.InitInsertCommandName) { //Add new" button clicked e.Canceled = true; //Prepare an IDictionary with the predefined values System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary(); newValues["Type"] = "0"; //Insert the item and rebind e.Item.OwnerTableView.InsertItem(newValues); } } } }<div class="exampleWrapper">
<telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1"> </telerik:RadAjaxLoadingPanel> <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="LoadingPanel1" Height="100%"> <div style="float:left; width:500px"> <telerik:RadTabStrip ID="RadTabStrip1" SelectedIndex="0" runat="server" MultiPageID="RadMultiPage1" Skin="Sunset" CssClass="tabStrip"> </telerik:RadTabStrip> <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" OnPageViewCreated="RadMultiPage1_PageViewCreated" CssClass="multiPage"> </telerik:RadMultiPage> </div> </telerik:RadAjaxPanel></div>
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
AddTab("Personal Info", true);
RadPageView pageView = new RadPageView();
pageView.ID = "Personal";
RadMultiPage1.PageViews.Add(pageView);
AddTab("Education Info", false);
AddTab("Professional Info", false);
}
}
private void AddTab(string tabName, bool enabled)
{
RadTab tab = new RadTab(tabName);
tab.Enabled = enabled;
RadTabStrip1.Tabs.Add(tab);
}
protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{
Control pageViewContents = LoadControl(e.PageView.ID + "CS.ascx");
pageViewContents.ID = e.PageView.ID + "userControl";
e.PageView.Controls.Add(pageViewContents);
}
User Control for Tab1
<asp:Button runat="server" ID="nextButton" Text="Next" OnClick="nextButton_Click" CssClass="nextButton" />
protected void nextButton_Click(object sender, EventArgs e)
{
GoToNextTab();
}
private void GoToNextTab()
{
RadTabStrip tabStrip = (RadTabStrip)Page.FindControl("RadTabStrip1");
RadTab educationInfoTab = tabStrip.FindTabByText("Education Info");
educationInfoTab.Enabled = true;
educationInfoTab.Selected = true;
GoToNextPageView();
}
private void GoToNextPageView()
{
RadMultiPage multiPage = (RadMultiPage)Page.FindControl("RadMultiPage1");
RadPageView educationInfoPageView = multiPage.FindPageViewByID("Education");
if (educationInfoPageView == null)
{
educationInfoPageView = new RadPageView();
educationInfoPageView.ID = "Education";
multiPage.PageViews.Add(educationInfoPageView);
}
educationInfoPageView.Selected = true;
}
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" /><telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="RequestStart" ClientEvents-OnResponseEnd="ResponseEnd" LoadingPanelID="RadAjaxLoadingPanel1"> <telerik:RadGrid ID="AccountGrid1" runat="server" OnNeedDataSource="AccountGrid1_NeedDataSource" OnSortCommand="AccountGrid1_SortCommand" OnGroupsChanging="AccountGrid1_GroupsChanging" OnColumnCreated="AccountGrid1_ColumnCreated" OnItemCreated="AccountGrid1_ItemCreated" AutoGenerateColumns="true" AllowPaging="true" AllowCustomPaging="true" AllowSorting="true" GroupingEnabled="true" ShowGroupPanel="true" ShowFooter="true" ShowHeader="true"> <GroupingSettings CaseSensitive="false" /> <MasterTableView DataKeyNames="Id,ClientId" ClientDataKeyNames="Id" AllowNaturalSort="false" AllowMultiColumnSorting="false" AllowCustomSorting="true" CommandItemDisplay="Top"> <CommandItemStyle HorizontalAlign="Right" /> <CommandItemTemplate> <asp:LinkButton ID="RefreshLinkButton" runat="server" CommandName="RebindGrid"><%= Navigator.Icon("Refresh", "refresh").ToHtmlImage() %> Refresh</asp:LinkButton> | <telerik:RadComboBox ID="gridStatCombo" runat="server" OnClientSelectedIndexChanged="EnableStatButton" DropDownWidth="250" Visible="false"> <Items> <telerik:RadComboBoxItem Text="Select a field to group by" Value="" /> </Items> </telerik:RadComboBox> <telerik:RadComboBox ID="gridStatDateCombo" runat="server" Width="75" Visible="false" Enabled="false"> <Items> <telerik:RadComboBoxItem Text="Day" Value="DAY" /> <telerik:RadComboBoxItem Text="Month" Value="MONTH" Selected="true" /> <telerik:RadComboBoxItem Text="Year" Value="YEAR" /> </Items> </telerik:RadComboBox> <telerik:RadButton ID="gridStatBtn" runat="server" Text="View Statistics" OnClick="Stat_Click" Enabled="false" Visible="false" /> | <telerik:RadComboBox ID="gridExportCombo" runat="server" OnClientSelectedIndexChanged="EnableExportButton" DropDownWidth="250"> <Items> <telerik:RadComboBoxItem Text="Select an export format" Value="" /> <telerik:RadComboBoxItem Text="Excel" Value="Excel" ImageUrl="~/Main/Content/Images/Icons/excel.png" /> <telerik:RadComboBoxItem Text="Word" Value="Word" ImageUrl="~/Main/Content/Images/Icons/ms_word_2.png" /> <telerik:RadComboBoxItem Text="PDF" Value="PDF" ImageUrl="~/Main/Content/Images/Icons/filetype_pdf.png" /> <telerik:RadComboBoxItem Text="Comma Separated Values (CSV)" Value="CSV" ImageUrl="~/Main/Content/Images/Icons/csv_file.png" /> <telerik:RadComboBoxItem Text="Tab-delimited" Value="Tab" ImageUrl="~/Main/Content/Images/Icons/txt_file.png" /> <telerik:RadComboBoxItem Text="Tab-delimited w/ Quotes" Value="TabQuote" ImageUrl="~/Main/Content/Images/Icons/txt_file.png" /> </Items> </telerik:RadComboBox> <telerik:RadButton ID="gridBtnExport" runat="server" Text="Export" OnClick="Export_Click" Enabled="false" /> </CommandItemTemplate> <PagerStyle AlwaysVisible="true" /> </MasterTableView> <ClientSettings AllowDragToGroup="true" AllowColumnsReorder="true"> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowDblClick="ViewAccount" OnGridCreated="ResizeAccountGrid" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="100%" /> </ClientSettings> <GroupingSettings ShowUnGroupButton="true" /> <FooterStyle HorizontalAlign="Right" /> <ExportSettings ExportOnlyData="true" HideStructureColumns="true" IgnorePaging="true"/> </telerik:RadGrid> <telerik:RadScriptBlock ID="AccountGridScriptBlock" runat="server"> <script type="text/javascript"> $(window).resize(function () { ResizeAccountGrid(); }); function ResizeAccountGrid(sender, eventArgs) { ResizeGrid($find("<%= AccountGrid1.ClientID %>")); } function ViewAccount(sender, eventArgs) { var accountId = eventArgs.get_gridDataItem().getDataKeyValue("Id"); ToolClick(null, null, "<%= Navigator.Inquiry() %>" + "?Id=" + accountId, "<%= (int)SiteNavigatorTab.Inquiry %>", false); } function RequestStart(sender, eventArgs) { //Log the start time startTime = new Date(); if (eventArgs.EventTarget.indexOf("gridBtnExport") > 0) { eventArgs.EnableAjax = false; } } function ResponseEnd(sender, eventArgs) { //Log the end time var endTime = new Date(); //Display the total time //$get("<%= lblTotal.ClientID %>").innerHTML = endTime - startTime + " ms"; } function EnableExportButton(sender, eventArgs) { var item = eventArgs.get_item(); var button = $find('<%= (AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]).FindControl("gridBtnExport").ClientID %>'); var selectedIndex = item.get_index(); button.set_enabled(selectedIndex != 0); } function EnableStatButton(sender, eventArgs) { var item = eventArgs.get_item(); var button = $find('<%= (AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]).FindControl("gridStatBtn").ClientID %>'); var dateBreak = $find('<%= (AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0]).FindControl("gridStatDateCombo").ClientID %>'); var selectedIndex = item.get_index(); button.set_enabled(selectedIndex != 0); var dateFields = "<%= JsDateTimeFields %>".split("|"); var text = item.get_text(); var exists = $.inArray(text, dateFields) > -1; dateBreak.set_enabled(exists); } </script> </telerik:RadScriptBlock></telerik:RadAjaxPanel>protected void Page_Load(object sender, EventArgs e){ var gridStatCombo = (RadComboBox)AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl("gridStatCombo"); var gridStatDateCombo = (RadComboBox)AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl("gridStatDateCombo"); var gridStatBtn = (RadButton)AccountGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0].FindControl("gridStatBtn"); foreach (var fieldName in Configuration[Vars.StatisticalReportFields].Value .Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries).OrderBy(f => f.Trim())) { if (!User.ParentCawClient.HasAccountField(fieldName)) continue; var field = User.ParentCawClient.GetAccountField(fieldName); gridStatCombo.Items.Add(new RadComboBoxItem(field.DisplayName, field.ColumnName)); if (SqlServerUtils.IsDateTimeSqlType(field.SqlDbType)) JsDateTimeFields += field.DisplayName + "|"; } if (gridStatCombo.Items.Count > 1) { gridStatCombo.Visible = true; gridStatDateCombo.Visible = true; gridStatBtn.Visible = true; }}