| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs" Inherits="TestGrid._Default2" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" > |
| <head runat="server"> |
| <title>Untitled Page</title> |
| <script type="text/javascript" src="script/jquery/1.3.2/jquery.js"></script> |
| <script type="text/javascript" src="json.js"></script> |
| <telerik:RadScriptBlock ID="SB" runat="server"> |
| <script type="text/javascript"> |
| var dataItems = new Array(); |
| var dataRows = 0; |
| var empId = -999; |
| var employee = |
| { |
| EmployeeID : null, |
| FirstName : null, |
| LastName : null, |
| Title : null, |
| TitleOfCourtesy : null, |
| BirthDate : null, |
| Notes : null, |
| create : function() |
| { |
| var obj = new Object(); |
| obj.EmployeeID = 0; |
| obj.FirstName = ""; |
| obj.LastName = ""; |
| obj.Title = ""; |
| obj.TitleOfCourtesy = ""; |
| obj.BirthDate = ""; |
| obj.Notes = ""; |
| return obj; |
| } |
| }; |
| $(document).ready(pageLoad); |
| function pageLoad() |
| { |
| var grd = $find("<%= RadGrid1.ClientID %>"); |
| //loadGrid(grd); //Approach 1 |
| loadGrid2(grd); //Approach 2 |
| } |
| function addEmployee() |
| { |
| var newEmployee = employee.create(); |
| newEmployee.FirstName = "Taimur"; |
| newEmployee.LastName = "Khan"; |
| newEmployee.EmployeeID = empId--; |
| newEmployee.Title = "Mr"; |
| newEmployee.Notes = "XYZ"; |
| newEmployee.BirthDate = "12-12-1970"; |
| var grd = $find("<%= RadGrid1.ClientID %>"); |
| //Approach 1 |
| //addNewItem(grd,newEmployee); |
| //Approach 2 |
| addNewItem2(grd,newEmployee); |
| dataItems[dataRows] = newEmployee; |
| document.getElementById("hdEmployees").value = $.toJSON(dataItems); |
| } |
| function loadGrid(grd) |
| { |
| if(grd == null) |
| return; |
| var masterTable = grd.get_masterTableView(); |
| if(masterTable == null) |
| return; |
| var ds = document.getElementById("hdEmployees").value; |
| if(ds && ds != "") |
| { |
| masterTable.set_dataSource($.parseJSON(ds)); |
| masterTable.dataBind(); |
| } |
| } |
| function addNewItem(grd,dataItem) |
| { |
| if(grd == null || dataItem == null) |
| return; |
| var masterTable = grd.get_masterTableView(); |
| if(masterTable == null) |
| return; |
| var ds = masterTable.get_dataSource(); |
| if(!ds) |
| ds = new Array(); |
| ds[ds.length] = dataItem; |
| masterTable.set_dataSource(ds); |
| masterTable.dataBind(); |
| document.getElementById("hdEmployees").value = $.toJSON(ds); |
| } |
| function loadGrid2(grd) |
| { |
| if(grd == null) |
| return; |
| var ds = document.getElementById("hdEmployees").value; |
| if(ds && ds != "") |
| { |
| dataItems = $.parseJSON(ds); |
| } |
| } |
| function addNewItem2(grd,dataItem) |
| { |
| var masterTable = grd.get_masterTableView(); |
| if(masterTable == null) |
| return; |
| if(dataRows == 0) |
| { |
| dataRows = masterTable.get_dataItems().length; |
| if(dataRows == 0) |
| { |
| //delete row of "No record" |
| masterTable._element.deleteRow(masterTable._element.rows.length-1); |
| } |
| } |
| var tBodyNode = null; |
| for(var i=0;i<masterTable._element.childNodes.length;i++) |
| { |
| var node = masterTable._element.childNodes[i]; |
| if(node.nodeName == "TBODY") |
| { |
| tBodyNode = node; |
| break; |
| } |
| } |
| if(tBodyNode != null) |
| { |
| tBodyNode.insertRow(-1); |
| var newRowIndex = masterTable._element.rows.length - 1; |
| var row = masterTable._element.rows[newRowIndex]; |
| row.id = masterTable._element.id + "__" + newRowIndex; |
| row.className = (dataRows == 0 || dataRows % 2 == 0) ? "rgRow" : "rgAltRow"; |
| debugger; |
| var columns = masterTable.get_columns(); |
| for(var i=0;i<columns.length;i++) |
| { |
| var uniqueName = columns[i]._data.UniqueName; |
| masterTable._element.rows[newRowIndex].insertCell(i); |
| var td = masterTable._element.rows[newRowIndex].cells[i]; |
| if(uniqueName == "EmployeeID") |
| { |
| td.innerHTML = dataItem.EmployeeID; |
| td.style.display = "none"; |
| } |
| if(uniqueName == "mode") |
| { |
| td.innerHTML = "Add"; |
| td.style.display = "none"; |
| } |
| if(uniqueName == "FirstName") |
| td.innerHTML = dataItem.FirstName; |
| if(uniqueName == "LastName") |
| td.innerHTML = dataItem.LastName; |
| if(uniqueName == "Title") |
| td.innerHTML = dataItem.Title; |
| if(uniqueName == "TitleOfCourtesy") |
| td.innerHTML = ""; |
| if(uniqueName == "BirthDate") |
| td.innerHTML = dataItem.BirthDate; |
| if(uniqueName == "Notes") |
| td.innerHTML = dataItem.Notes; |
| } |
| dataRows++; |
| } |
| } |
| function OnCommand(sender,args) |
| { |
| debugger; |
| $get("<%= Panel1.ClientID %>").innerHTML = String.format("<b>RadGrid1_Command</b><br />CommandName : {0}, CommandArgument : {1} <br /><br />", args.get_commandName(), args.get_commandArgument()); |
| //args.set_cancel(true); |
| if(args.get_commandName() == "InitInsert") |
| { |
| alert(""); |
| } |
| var currentPageIndex = sender.get_masterTableView().get_currentPageIndex(); |
| var pageSize = sender.get_masterTableView().get_pageSize(); |
| var sortExpressions = sender.get_masterTableView().get_sortExpressions(); |
| var filterExpressions = sender.get_masterTableView().get_filterExpressions(); |
| if(sortExpressions.length > 0 && filterExpressions.length > 0 && currentPageIndex > 0) |
| { |
| sender.get_masterTableView().set_currentPageIndex(0); |
| } |
| var sortExpressionssortExpressionsAsSQL = sortExpressions.toString(); |
| var filterExpressionsfilterExpressionsAsSQL = filterExpressions.toString(); |
| } |
| function OnRowDataBound(sender,args) |
| { |
| var row = sender.get_masterTableView().get_dataItems()[0]; |
| var cell = sender.get_masterTableView().getCellByColumnUniqueName(row, "CurrencyId"); |
| // conditional formatting |
| args.get_item().get_cell("TitleOfCourtesy").style.fontWeight = (args.get_dataItem()["TitleOfCourtesy"] == "Dr.")? "bold" : "normal"; |
| var sb = new Sys.StringBuilder(); |
| sb.appendLine("<b>RadGrid1_RowDataBound</b><br />"); |
| for(var item in args.get_dataItem()) |
| { |
| sb.appendLine(String.format("{0} : {1}<br />", item, args.get_dataItem()[item])); |
| } |
| sb.appendLine("<br />"); |
| sb.appendLine("<br />"); |
| $get("<%= Panel1.ClientID %>").innerHTML += sb.toString(); |
| } |
| function OnDataBinding(sender,args) |
| { |
| } |
| function OnRowCreating(sender,args) |
| { |
| } |
| </script> |
| </telerik:RadScriptBlock> |
| </head> |
| <body > |
| <form id="form1" runat="server"> |
| <div> |
| <asp:ScriptManager ID="ScriptManager1" runat="server" ></asp:ScriptManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1NeedDataSource" > |
| <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" AllowAutomaticInserts="true" DataKeyNames="EmployeeID" CommandItemDisplay="Top"> |
| <Columns> |
| <telerik:GridBoundColumn DataField="EmployeeID" Display="false" DataType="System.Int32"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="mode" Display="false"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Title" HeaderText="Title"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="TitleOfCourtesy" HeaderText="Title Of Courtesy" > |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="BirthDate" HeaderText="BirthDate" > |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Notes" HeaderText="Notes"> |
| </telerik:GridBoundColumn> |
| <telerik:GridTemplateColumn HeaderText="Curr" UniqueName="CurrencyId"> |
| <HeaderStyle Width="40px" HorizontalAlign="Center" VerticalAlign="Top" /> |
| <ItemTemplate> |
| <asp:DropDownList |
| ID="drpCurrency" |
| runat="server" |
| Enabled="true" |
| CssClass="select" |
| Width="50px" |
| onchange="DoCalculations(event);" > |
| <asp:ListItem Text="Item 1" Value="1">Item 1</asp:ListItem> |
| <asp:ListItem Text="Item 2" Value="2">Item 2</asp:ListItem> |
| <asp:ListItem Text="Item 3" Value="3">Item 3</asp:ListItem> |
| </asp:DropDownList> |
| </ItemTemplate> |
| <ItemStyle Width="5%" HorizontalAlign="Center" VerticalAlign="Top" /> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| <CommandItemTemplate> |
| <input type="button" value="+" id="add" onclick="addEmployee();" /> |
| </CommandItemTemplate> |
| </MasterTableView> |
| <ClientSettings> |
| <ClientEvents OnCommand="OnCommand" OnDataBinding="OnDataBinding" OnRowCreating="OnRowCreating" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| <asp:Button ID="button1" runat="server" OnClick="button1_Click" /> |
| <asp:HiddenField ID="hdEmployees" runat="server" /> |
| </div> |
| <br /> |
| <br /> |
| Events: |
| <asp:Panel ID="Panel1" Style="height: 200px; overflow: auto; padding: 15px;" CssClass="module" |
| runat="server"> |
| </asp:Panel> |
| </form> |
| </body> |
| </html> |
| using System; |
| using System.Collections; |
| using System.Collections.Generic; |
| using System.Configuration; |
| using System.Data; |
| using System.Linq; |
| using System.Web; |
| using System.Web.Security; |
| using System.Web.UI; |
| using System.Web.UI.HtmlControls; |
| using System.Web.UI.WebControls; |
| using System.Web.UI.WebControls.WebParts; |
| using System.Xml.Linq; |
| using System.Web.Services; |
| using System.Web.Script.Services; |
| using System.Reflection; |
| using Newtonsoft.Json; |
| using Newtonsoft.Json.Schema; |
| using CS.DataAccessLayer.EntityClasses; |
| using CS.DataAccessLayer.CollectionClasses; |
| using CS.CommonLib.ErrorHandling; |
| using CS.BusinessClasses.Helpers; |
| using CS.BusinessClasses.SystemAndApp; |
| using CS.DataAccessLayer.HelperClasses; |
| using CS.DataAccessLayer; |
| using CS.BusinessClasses; |
| using Telerik.Web.UI; |
| using System.Globalization; |
| using System.Drawing; |
| using CS.DataAccessLayer.CSTypes; |
| using CS.DataAccessLayer.FactoryClasses; |
| using CS.DataAccessLayer.DaoClasses; |
| using CS.DataAccessLayer.RelationClasses; |
| //Check line 1651 |
| using SD.LLBLGen.Pro.ORMSupportClasses; |
| namespace TestGrid |
| { |
| public partial class _Default2 : System.Web.UI.Page |
| { |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| } |
| protected void RadGrid1NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| RadGrid1.MasterTableView.DataSource = Employees; |
| } |
| protected void button1_Click(object sender, EventArgs e) |
| { |
| _employees = (List<Employee>)JsonConvert.DeserializeObject(hdEmployees.Value, typeof(List<Employee>)); |
| RadGrid1.Rebind(); |
| } |
| private List<Employee> _employees = new List<Employee>(); |
| public List<Employee> Employees |
| { |
| get { return _employees; } |
| } |
| } |
| public class Employee |
| { |
| string firstName = ""; |
| public string FirstName |
| { |
| get { return firstName; } |
| set { firstName = value; } |
| } |
| int employeeId = 0; |
| public int EmployeeID |
| { |
| get { return employeeId; } |
| set { employeeId = value; } |
| } |
| string lastName = ""; |
| public string LastName |
| { |
| get { return lastName; } |
| set { lastName = value; } |
| } |
| string title = ""; |
| public string Title |
| { |
| get { return title; } |
| set { title = value; } |
| } |
| string toc = ""; |
| public string TitleOfCourtesy |
| { |
| get { return toc; } |
| set { toc = value; } |
| } |
| public string BirthDate = ""; |
| public string Notes = ""; |
| } |
| } |
I'm encountering an issue where controls in the HeaderTemplate do not seem to be updated via AJAX callbacks from the RadGrid.
ASP.NET version: 3.5
OS: Windows XP SP2
Browser: IE 7
RadControls version: Q1 2009
Language: C#
I have a template column that includes 5 "virtual" columns both within the ItemTemplate, EditItemTemplate and the HeaderTemplate for the column. I'm attempting to implement sorting on each of these "virtual" columns in a like manner to the other columns using the default RadGrid sorting functionality. Currently I'm attempting to use Labels to indicate the sort direction for each of these columns. One indicating ASC, and one DESC, with the idea of simply changing visibility to visually indicate the sort order for the column. I have an entry for the RadGrid within the RadAjaxManagerProxy to update the Label controls in question. However, while the event is raised properly and I can see change in visisbility applied to the Label in question, the change does not seem to be pushed down to the Label control within the HeaderTemplate from the AJAX call.
Relevant ASPX Code
| <telerik:RadAjaxManagerProxy ID="EntityMainAjaxProxy" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="EandP_Details"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="EandP_Details" /> |
| <telerik:AjaxUpdatedControl ControlID="rdgridAllCFCs" /> |
| <telerik:AjaxUpdatedControl ControlID="rdgridSoloCFC" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="rdgridAllCFCs"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="rdgridAllCFCs" /> |
| <telerik:AjaxUpdatedControl ControlID="lblAsc_PTI" /> |
| <telerik:AjaxUpdatedControl ControlID="lblDesc_PTI" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| <telerik:AjaxSetting AjaxControlID="rdgridSoloCFC"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="rdgridSoloCFC" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManagerProxy> |
| ... |
| <telerik:RadGrid ID="rdgridAllCFCs" runat="server" AllowPaging="false" GridLines="None" Skin="Office2007" AllowSorting="true" |
| OnNeedDataSource="rdgridAllCFCs_NeedDataSource" OnItemDataBound="rdgridAllCFCs_ItemDataBound" OnItemCommand="rdgridAllCFCs_ItemCommand"> |
| <ClientSettings EnablePostBackOnRowClick="true"></ClientSettings> |
| <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" ShowFooter="true" CellPadding="0" CellSpacing="0"> |
| <Columns> |
| <telerik:GridTemplateColumn SortExpression="Entity" HeaderText="Entity" UniqueName="Entity" ShowSortIcon="true" HeaderButtonType="TextButton"> |
| <ItemTemplate> |
| <asp:Label ID="lblEntity" runat="server"></asp:Label> |
| </ItemTemplate> |
| <ItemStyle HorizontalAlign="Left" /> |
| <FooterTemplate> |
| <asp:Label ID="lblTotal" runat="server">Total</asp:Label> |
| </FooterTemplate> |
| <FooterStyle HorizontalAlign="Right" Font-Bold="true" BackColor="#d3dbe9" Font-Size="Larger" BorderWidth="2px" BorderColor="Black" BorderStyle="Solid"/> |
| <HeaderStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn SortExpression="CC_Name" HeaderText="Country" UniqueName="CC_Name" ShowSortIcon="true" HeaderButtonType="TextButton"> |
| <ItemTemplate> |
| <asp:Label ID="lblCountry" runat="server"></asp:Label> |
| </ItemTemplate> |
| <ItemStyle HorizontalAlign="Left" /> |
| <FooterTemplate> |
| |
| </FooterTemplate> |
| <FooterStyle BackColor="Gray" BorderWidth="2px" BorderColor="Gray" BorderStyle="Solid"/> |
| <HeaderStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn SortExpression="C_Name" HeaderText="Functional<br/>Currency" UniqueName="C_Name" ShowSortIcon="true" HeaderButtonType="TextButton"> |
| <ItemTemplate> |
| <asp:Label ID="lblCurrency" runat="server"></asp:Label> |
| </ItemTemplate> |
| <ItemStyle HorizontalAlign="Left" /> |
| <FooterTemplate> |
| |
| </FooterTemplate> |
| <FooterStyle BackColor="Gray" BorderWidth="2px" BorderColor="Gray" BorderStyle="Solid"/> |
| <HeaderStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn SortExpression="SpotRate" HeaderText="Current Spot Rate" UniqueName="SpotRate" ShowSortIcon="true" HeaderButtonType="TextButton"> |
| <ItemTemplate> |
| <asp:Label ID="lblSpot" runat="server"></asp:Label> |
| </ItemTemplate> |
| <ItemStyle HorizontalAlign="Right" /> |
| <FooterTemplate> |
| |
| </FooterTemplate> |
| <FooterStyle BackColor="Gray" BorderWidth="2px" BorderColor="Gray" BorderStyle="Solid"/> |
| <HeaderStyle HorizontalAlign="Center" /> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn > |
| <HeaderTemplate> |
| <table style="text-align: center; border-color: Black; border-style:solid; border-width:thin; width:380px; margin: 0" cellspacing="0" cellpadding="2"> |
| <tr> |
| <td colspan="3" style="border-color: Black; border-right-style:solid; border-right-width:thin; border-bottom-style:solid; border-bottom-width:thin; text-align:center; width: 210px"> |
| 959(c)(3) |
| </td> |
| <td style="border-right-style:solid; border-right-width: 1px; border-right-color:Black; width:70px; vertical-align:bottom" rowspan="2"> |
| <asp:LinkButton ID="btnPTISort" runat="server" ToolTip="Click here to sort" CommandName="TemplateSort" CommandArgument="PTI">PTI<br />(US$)</asp:LinkButton> |
| <asp:Label ID="lblAsc_PTI" runat="server" Visible="false">></asp:Label> |
| <asp:Label ID="lblDesc_PTI" runat="server" Visible="false"><</asp:Label> |
| </td> |
| <td style="width:90px; vertical-align:bottom" rowspan="2"> |
| <asp:LinkButton ID="btnFXSort" runat="server" ToolTip="Click here to sort" CommandName="TemplateSort" CommandArgument="FX">Built-in FX<br />Gain/(Loss)<br />(US$)</asp:LinkButton> |
| <asp:Label ID="lblAsc_FX" runat="server" Visible="false">></asp:Label> |
| <asp:Label ID="lblDesc_FX" runat="server" Visible="false"><</asp:Label> |
| </td> |
| </tr> |
| <tr> |
| <td style="border-right-style:solid; border-right-width: 1px; border-right-color:Black; width:70px; vertical-align:bottom"> |
| <asp:LinkButton ID="btnEandPUSSort" runat="server" ToolTip="Click here to sort" CommandName="TemplateSort" CommandArgument="EandPUS">E & P<br />(US$)</asp:LinkButton> |
| <asp:Label ID="lblAsc_EandPUS" runat="server" Visible="false">></asp:Label> |
| <asp:Label ID="lblDesc_EandPUS" runat="server" Visible="false"><</asp:Label> |
| </td> |
| <td style="border-right-style:solid; border-right-width: 1px; border-right-color:Black; width:70px; vertical-align:bottom"> |
| <asp:LinkButton ID="btnTaxesUSSort" runat="server" ToolTip="Click here to sort" CommandName="TemplateSort" CommandArgument="TaxesUS">Taxes<br />(US$)</asp:LinkButton> |
| <asp:Label ID="lblAsc_TaxesUS" runat="server" Visible="false">></asp:Label> |
| <asp:Label ID="lblDesc_TaxesUS" runat="server" Visible="false"><</asp:Label> |
| </td> |
| <td style="border-color: Black; border-right-style:solid; border-right-width:thin; width:70px; vertical-align:bottom"> |
| <asp:LinkButton ID="btnEffRateSort" runat="server" ToolTip="Click here to sort" CommandName="TemplateSort" CommandArgument="EffRate" >Effective<br />Rate</asp:LinkButton> |
| <asp:Label ID="lblAsc_EffRate" runat="server" Visible="false">></asp:Label> |
| <asp:Label ID="lblDesc_EffRate" runat="server" Visible="false"><</asp:Label> |
| </td> |
| </tr> |
| </table> |
| </HeaderTemplate> |
| <HeaderStyle HorizontalAlign="Left" Width="370px"/> |
| <ItemTemplate> |
| <table style="text-align:center; width:380px; border-style: none; margin:0" cellspacing="0" cellpadding="2"> |
| <tr> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblUSD" runat="server">1,260</asp:Label> |
| </td> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblTaxesUSD" runat="server">350</asp:Label> |
| </td> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblEffRate" runat="server">27.78%</asp:Label> |
| </td> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblPTIUSD" runat="server">715</asp:Label> |
| </td> |
| <td style="text-align:right; width:90px; border-style:none"> |
| <asp:Label ID="lblGLUSD" runat="server">59</asp:Label> |
| </td> |
| </tr> |
| </table> |
| </ItemTemplate> |
| <ItemStyle HorizontalAlign="Left" Width="370px"/> |
| <FooterTemplate> |
| <table style="text-align:center; width:380px; border-style: none" cellspacing="0" cellpadding="2"> |
| <tr> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblTotalUSD" runat="server">1,260</asp:Label> |
| </td> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblTotalTaxesUSD" runat="server">350</asp:Label> |
| </td> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblTotalEffRate" runat="server">27.78%</asp:Label> |
| </td> |
| <td style="text-align:right; width:70px; border-style:none"> |
| <asp:Label ID="lblTotalPTIUSD" runat="server">715</asp:Label> |
| </td> |
| <td style="text-align:right; width:90px; border-style:none"> |
| <asp:Label ID="lblTotalGLUSD" runat="server">59</asp:Label> |
| </td> |
| </tr> |
| </table> |
| </FooterTemplate> |
| <FooterStyle Width="370px" Font-Bold="true" Font-Size="Larger" BackColor="#d3dbe9" BorderWidth="2px" BorderColor="Black" BorderStyle="Solid"/> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
================================================================================================
Relevant C# Code
| protected void rdgridAllCFCs_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| switch (e.CommandName) |
| { |
| case "TemplateSort": |
| LinkButton btn = e.Item.FindControl("btn" + e.CommandArgument.ToString() + "Sort") as LinkButton; |
| if (btn != null) |
| SortTemplateColumn(btn, e.CommandArgument.ToString()); |
| break; |
| default: |
| break; |
| } |
| } |
| private void SortTemplateColumn(LinkButton btn, string fieldName) |
| { |
| Label up = btn.Parent.FindControl("lblAsc_" + fieldName) as Label; |
| Label down = btn.Parent.FindControl("lblDesc_" + fieldName) as Label; |
| GridSortOrder sortDirection; |
| GridSortExpression newSort = new GridSortExpression(); |
| newSort.FieldName = fieldName; |
| if ((up == null) || (down == null)) |
| return; //Can't proceed without up and down indicators |
| if ((up.Visible == false) && (down.Visible == false)) |
| sortDirection = GridSortOrder.None; |
| else if (up.Visible == true) |
| sortDirection = GridSortOrder.Ascending; |
| else |
| sortDirection = GridSortOrder.Descending; |
| switch (sortDirection) |
| { |
| case GridSortOrder.None: |
| newSort.SortOrder = GridSortOrder.Ascending; |
| up.Visible = true; |
| down.Visible = false; |
| break; |
| case GridSortOrder.Ascending: |
| newSort.SortOrder = GridSortOrder.Descending; |
| up.Visible = false; |
| down.Visible = true; |
| break; |
| case GridSortOrder.Descending: |
| newSort.SortOrder = GridSortOrder.None; |
| up.Visible = false; |
| down.Visible = false; |
| break; |
| } |
| rdgridAllCFCs.MasterTableView.SortExpressions.AddSortExpression(newSort); |
| rdgridAllCFCs.Rebind(); |
| } |
<
telerik:RadGrid ID="RadGrid1" runat="server"
oncolumncreated="RadGrid1_ColumnCreated" AutoGenerateColumns="False"
onupdatecommand="RadGrid1_UpdateCommand" AutoGenerateEditColumn="True"
GridLines="None" onitemdatabound="RadGrid1_ItemDataBound1" AllowAutomaticUpdates="true" >
<MasterTableView GridLines="None" Width="100%" EditMode="PopUp" DataSourceID="OpenAccessDataSource1" DataKeyNames="CustomerID" CommandItemDisplay="Top" >
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" />
<telerik:GridBoundColumn DataField="CustomerID"
DataType="System.Int32"
HeaderText="CustomerID"
SortExpression="CustomerID"
UniqueName="CustomerID" />
<telerik:GridBoundColumn
DataField="Name1"
HeaderText="Name1"
SortExpression="Name1"
UniqueName="Name1" />
<telerik:GridBoundColumn
DataField="Name2"
HeaderText="Name2"
SortExpression="Name2"
UniqueName="Name2" />
<telerik:GridBoundColumn
DataField="Street1"
HeaderText="Street1"
SortExpression="Street1"
UniqueName="Street1" />
<telerik:GridBoundColumn
DataField="Street2"
HeaderText="Street2"
SortExpression="Street2"
UniqueName="Street2" />
<telerik:GridBoundColumn
DataField="City"
HeaderText="City"
SortExpression="City"
UniqueName="City" />
<telerik:GridBoundColumn
DataField="Zip"
HeaderText="Zip"
SortExpression="Zip"
UniqueName="Zip" />
<telerik:GridBoundColumn
DataField="Phone"
HeaderText="Phone"
SortExpression="Phone"
UniqueName="Phone" />
<telerik:GridBoundColumn
DataField="Fax"
HeaderText="Fax"
SortExpression="Fax"
UniqueName="Fax" />
<telerik:GridBoundColumn
DataField="Mobile"
HeaderText="Mobile"
SortExpression="Mobile"
UniqueName="Mobile" />
<telerik:GridBoundColumn
DataField="Website"
HeaderText="Website"
SortExpression="Website"
UniqueName="Website" />
</Columns>
<EditFormSettings ColumnNumber="2" CaptionDataField="CustomerID">
<FormTableItemStyle Wrap="False"></FormTableItemStyle>
<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
<FormMainTableStyle CellSpacing="0" CellPadding="3" Width="100%" />
<FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" CssClass="module"
Height="110px" Width="100%" />
<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
<FormStyle Width="100%" BackColor="#EEF2EA"></FormStyle>
<EditColumn UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit">
</EditColumn>
<FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
</EditFormSettings>
<ExpandCollapseColumn Visible="False">
<HeaderStyle Width="19px"></HeaderStyle>
</ExpandCollapseColumn>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
</MasterTableView>
</telerik:RadGrid>
And here is my update function (just a test). This won't work, because the values are still the same. After executing the update a get a javascript error (concurrent updates).
protected
void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope();
var customer = from c in scope.Extent<Customer>()
where c.CustomerID == 4 select c;
scope.Transaction.Begin();
foreach (Customer cust in customer)
{
cust.Name1 = (editedItem[
"Name1"].Controls[0] as TextBox).Text;
cust.Name2 = (editedItem[
"Name2"].Controls[0] as TextBox).Text;
cust.Street1 = (editedItem[
"Street1"].Controls[0] as TextBox).Text;
cust.Street2 = (editedItem[
"Street2"].Controls[0] as TextBox).Text;
cust.City = (editedItem[
"City"].Controls[0] as TextBox).Text;
cust.Zip = (editedItem[
"Zip"].Controls[0] as TextBox).Text;
cust.Phone = (editedItem[
"Phone"].Controls[0] as TextBox).Text;
cust.Fax = (editedItem[
"Fax"].Controls[0] as TextBox).Text;
cust.Mobile = (editedItem[
"Mobile"].Controls[0] as TextBox).Text;
cust.Website = (editedItem[
"Website"].Controls[0] as TextBox).Text;
}
scope.Transaction.Commit();
}
| function UpdateAllChildren(nodes, checked) | |
| { | |
| var i; | |
| for (i=0; i<nodes.get_count(); i++) | |
| { | |
| if (checked) | |
| { | |
| nodes.getNode(i).check(); | |
| } | |
| else | |
| { | |
| nodes.getNode(i).set_checked(false); | |
| } | |
| if (nodes.getNode(i).get_nodes().get_count()> 0) | |
| { | |
| UpdateAllChildren(nodes.getNode(i).get_nodes(), checked); | |
| } | |
| } | |
| } | |
| function DoClientNodeChecked(sender, eventArgs) | |
| { | |
| debugger | |
| if(!eventArgs.get_node().get_expanded()) | |
| { | |
| eventArgs.get_node().set_expanded(true); | |
| } | |
| var childNodes; | |
| while(eventArgs.get_node().get_nodes() == null) | |
| { | |
| childNodes = eventArgs.get_node().get_nodes(); | |
| } | |
| var isChecked = eventArgs.get_node().get_checked(); | |
| UpdateAllChildren(childNodes, isChecked); | |
| } |
| function openWin() |
| { |
| var oWnd = radopen("SegmentTable.aspx?st=1", "RadWindow1"); |
| oWnd.setSize(340,340); |
| //set a function to be called when RadWindow is closed |
| oWnd.add_close(OnClientClose); |
| } |
| function OnClientClose(oWnd) |
| { |
| alert('wtf'); |
| } |
I'm allowing users to upload a file, using radUpload in one of my applications. In production, when I upload a file more than 30mb, I get the following error immediately:
Due to the presence of characters known to be used in Cross Site Scripting attacks, access is forbidden. This web site does not allow Urls which might include embedded HTML tags.
I have verified that it's not the file name. I have created two files called "myUpload20.zip" (20mb) and "myUpload40.zip" (40mb). The 20 mb uploads fine. I can't replicate it in Dev and UAT environment. In these environment, I am able to upload files over 40mb with no issues. I have verified the web.configs in all 3 and they all have:
<!--file upload size 100mb : 30 min-->
<
httpRuntime maxRequestLength="102400" executionTimeout="1800" />
Is this a server issue? Any ideas how I can eliminate the error?