or
private void InitializeComponent(){ this.DataBinding += new System.EventHandler(this.RandomName_DataBound);}ComboBox.ItemTemplate = new ItemTemplate();ComboBox.ItemDataBound += ComboBox_ItemDataBound;ComboBox.Width = Unit.Pixel(500);ComboBox.AllowCustomText = true;ComboBox.MarkFirstMatch = true;ComboBox.DataSource = GetVendorList();ComboBox.DataTextField = "Name";ComboBox.DataBind();foreach (RadComboBoxItem item in ComboBox.Items){ item.DataBind();}protected void RandomName_DataBound(object sender, EventArgs e){ // do stuff here}class ItemTemplate : ITemplate{ public void InstantiateIn(Control container) { Table table = new Table(); table.Width = Unit.Percentage(100); TableRow mainRow = new TableRow(); TableCell cell1 = new TableCell(); cell1.Width = Unit.Percentage(40); cell1.DataBinding += new EventHandler(cell1_DataBinding); mainRow.Cells.Add(cell1); TableCell cell2 = new TableCell(); cell2.DataBinding += new EventHandler(cell2_DataBinding); cell2.Width = Unit.Percentage(30); mainRow.Cells.Add(cell2); TableCell cell3 = new TableCell(); cell3.DataBinding += new EventHandler(cell3_DataBinding); cell3.Width = Unit.Percentage(30); mainRow.Cells.Add(cell3); table.Rows.Add(mainRow); container.Controls.Add(table); } private void cell1_DataBinding(object sender, EventArgs e) { TableCell target = (TableCell)sender; RadComboBoxItem item = (RadComboBoxItem)target.BindingContainer; target.Text = (string)DataBinder.Eval(item, "Text"); } private void cell2_DataBinding(object sender, EventArgs e) { TableCell target = (TableCell)sender; RadComboBoxItem item = (RadComboBoxItem)target.BindingContainer; target.Text = (string)DataBinder.Eval(item, "Attributes[\"Type\"]"); } private void cell3_DataBinding(object sender, EventArgs e) { TableCell target = (TableCell)sender; RadComboBoxItem item = (RadComboBoxItem)target.BindingContainer; target.Text = (string)DataBinder.Eval(item, "Attributes[\"Phone\"]"); }}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %><!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></title> <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" /></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <%--Needed for JavaScript IntelliSense in VS2010--%> <%--For VS2008 replace RadScriptManager with ScriptManager--%> <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" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <script type="text/javascript"> //Put your JavaScript code here. </script> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadButtonAdd"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadTabStripContent" /> <telerik:AjaxUpdatedControl ControlID="LabelCount" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="RadButtonClose_Click"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadTabStripContent" /> <telerik:AjaxUpdatedControl ControlID="LabelCount" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <div style="height: 100px; background-color: gray;"> <telerik:RadTabStrip ID="RadTabStripContent" runat="server" Skin="Simple" ScrollChildren="true" dir="LTL" EnableEmbeddedSkins="true" Visible="true"> <TabTemplate> <asp:Label ID="LabelTabName" runat="server" /> Tab </TabTemplate> </telerik:RadTabStrip> </div> <telerik:RadButton runat="server" ID="RadButtonAdd" Text="Add" OnClick="RadButtonAdd_Click"></telerik:RadButton> <telerik:RadButton runat="server" ID="RadButtonClose" Text="close" OnClick="RadButtonClose_Click"></telerik:RadButton> <asp:Label runat="server" ID="LabelCount" Text="Tab Count:"></asp:Label> </form></body></html>using System;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Data;using System.Configuration;using System.Web.Security;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using Telerik.Web.UI;public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void RadButtonClose_Click(object sender, EventArgs e) { RadTabStripContent.Tabs.RemoveAt(RadTabStripContent.Tabs.Count -4); LabelCount.Text = "Tab Count:" + RadTabStripContent.Tabs.Count; } protected void RadButtonAdd_Click(object sender, EventArgs e) { RadTab tab = new RadTab(); tab.Text = "TAB "+ (RadTabStripContent.Tabs.Count + 1).ToString(); RadTabStripContent.Tabs.Add(tab); LabelCount.Text = "Tab Count:" + RadTabStripContent.Tabs.Count; }}
Hello techies,
We are using the RagGrid on a test page for performance testing.
We were surprised to notice that a simple page with 100 elements in the GRID takes on an average about 2 seconds. We are doing a load test on Win Server 2008 R2. We are not using a real database. We are using a STUB to generate the 100 odd elements.
The same STUB when used on ASP.net MVC page with simple HTML table rendering out performs the RadGrid Page. The MVC page takes about 0.37 seconds.
Test Environment : ASP.net 4.0 / RadControls for ASP.NET AJAX Q2 2011 SP1 / Windows Server 2008 R2 / IIS 7.5 / Application pool type “Integrated Pipeline”
Any ideas?
Advance thanks,
<telerik:RadComboBox ID="rcbSiteSearch" runat="server" Width="190px" Height="100px" EnableLoadOnDemand="True" ShowMoreResultsBox="true" MarkFirstMatch="true" AllowCustomText="true" EnableVirtualScrolling="true" OnItemsRequested="rcbSiteSearch_ItemsRequested" />Protected Sub rcbSiteSearch_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs) Const ItemsPerRequest As Integer = 5 Dim data As DataTable = GetSiteName(e.Text) Dim itemOffset As Integer = e.NumberOfItems Dim endOffset As Integer = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count) e.EndOfItems = endOffset = data.Rows.Count For i As Integer = itemOffset To endOffset - 1 rcbSiteSearch.Items.Add(New RadComboBoxItem(data.Rows(i)("name").ToString(), data.Rows(i)("value").ToString())) Next e.Message = GetStatusMessage(endOffset, data.Rows.Count) End Sub Private Shared Function GetSiteName(ByVal text As String) As DataTable Dim StateCode As String = "pa" Dim connectionString As String = *Connection String* Dim QueryStr As String = *QUERY* Dim adapter As New SqlDataAdapter(QueryStr,connectionString) Dim Data As New DataTable() Try adapter.Fill(Data) Catch ex As Exception Call MsgBox(String.Format("Unexpected Error: {0}", ex.ToString()), 0, "Unexpected Search Error") End Try Return Data End Function Private Shared Function GetStatusMessage(ByVal offset As Integer, ByVal total As Integer) As String If total <= 0 Then Return "No matches" End If Return [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total) End Functionprotected virtual void SetupGridProperties(int pageSize) { _gridObj.Width = Unit.Percentage(97); _gridObj.Height = Unit.Percentage(95); _gridObj.ID = "gridRpt"; _gridObj.Skin = ConfigurationManager.AppSettings.Get("WebGridStyle"); _gridObj.AllowPaging = true; _gridObj.PageSize = pageSize; _gridObj.PagerStyle.Mode = GridPagerMode.NextPrevNumericAndAdvanced; _gridObj.PagerStyle.Position = GridPagerPosition.Top; _gridObj.PagerStyle.AlwaysVisible = false; _gridObj.AllowSorting = true; _gridObj.GridLines = GridLines.Both; _gridObj.AllowMultiRowSelection = false; _gridObj.ClientSettings.AllowColumnsReorder = true; _gridObj.ClientSettings.ColumnsReorderMethod = GridClientSettings.GridColumnsReorderMethod.Reorder; _gridObj.ClientSettings.Selecting.AllowRowSelect = true; _gridObj.ClientSettings.Selecting.CellSelectionMode = GridCellSelectionMode.SingleCell; _gridObj.ClientSettings.Selecting.CellSelectionMode = GridCellSelectionMode.MultiCell; // _gridObj.ClientSettings.Selecting.AllowCellSelect = true; // _gridObj.ClientSettings.Selecting.AllowMultiCellSelect = true; _gridObj.ClientSettings.ClientEvents.OnGridCreated = "gridRpt_GridCreated"; //_gridObj.ClientSettings.ClientEvents.OnRowMouseOver = "_gridObj_RowMouseOver"; _gridObj.ClientSettings.ClientEvents.OnRowSelecting = "gridRpt_OnRowSelecting"; _gridObj.ClientSettings.ClientEvents.OnRowDeselecting = "gridRpt_OnRowDeSelecting"; _gridObj.ClientSettings.ClientEvents.OnRowClick = "gridRpt_OnRowClick"; //_gridObj.ClientSettings.Resizing.AllowRowResize = true; _gridObj.ClientSettings.Scrolling.AllowScroll = true; _gridObj.ClientSettings.Scrolling.UseStaticHeaders = true; _gridObj.GroupPanel.Visible = false; _gridObj.ClientSettings.AllowDragToGroup = true; _gridObj.GroupingEnabled = true; _gridObj.ShowGroupPanel = true; _gridObj.GroupPanel.Enabled = true; _gridObj.MasterTableView.TableLayout = GridTableLayout.Auto; _gridObj.ItemStyle.VerticalAlign = VerticalAlign.Middle; //this._gridObj.ExportSettings.IgnorePaging = true; //this._gridObj.ExportSettings.OpenInNewWindow = true; //this._gridObj.ExportSettings.IgnorePaging = true; _gridObj.MasterTableView.SortExpressions.AllowNaturalSort = false; _gridObj.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind; _gridObj.AutoGenerateColumns = false; _gridObj.MasterTableView.AutoGenerateColumns = false; }<form id="form1" runat="server"> <div> <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"> </telerik:RadScriptManager> <telerik:RadProgressManager ID="RadProgressManager1" Runat="server" /> <br /> <table style="width:100%;"> <tr> <td> <telerik:RadUpload ID="RadUpload1" Runat="server" AllowedFileExtensions=".jpg,.jpeg" OverwriteExistingFiles="True" TargetFolder="image/image_utenti"> </telerik:RadUpload> </td> <td> <asp:Label ID="Label1" runat="server" Text="Nessun file caricato"></asp:Label> </td> </tr> <tr> <td> <telerik:RadProgressArea ID="RadProgressArea1" Runat="server"> </telerik:RadProgressArea> </td> <td> <asp:Repeater ID="Repeater1" runat="server" Visible="False"> <HeaderTemplate> <div class="title"> File caricato:</div> </HeaderTemplate> <ItemTemplate> <%#DataBinder.Eval(Container.DataItem, "FileName")%> <%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%> <br /> </ItemTemplate> </asp:Repeater> </td> </tr> <tr> <td> <asp:Button ID="Button1" runat="server" Text="Button" /> </td> <td> </td> </tr> </table> </div> </form>
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.IO
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.Web.UI
Public Class UploadImgCard
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadUpload1.UploadedFiles.Count > 0 Then
Repeater1.DataSource = RadUpload1.UploadedFiles
Repeater1.DataBind()
Label1.Visible = False
Repeater1.Visible = True
Else
Label1.Visible = True
Repeater1.Visible = False
End If
End Sub
Private callBack As CacheItemRemovedCallback
Private Sub AddDeleteDependencyForFile(ByVal uploadedFileCollection As UploadedFileCollection)
Dim uploadedFile As UploadedFile
For Each uploadedFile In uploadedFileCollection
Dim timeOut As TimeSpan = TimeSpan.FromMinutes(5)
callBack = New CacheItemRemovedCallback(AddressOf DeleteFile)
Dim fullPath As String = Path.Combine(Server.MapPath(RadUpload1.TargetFolder), uploadedFile.GetName())
Context.Cache.Insert(uploadedFile.FileName, fullPath, Nothing, DateTime.Now.Add(timeOut), TimeSpan.Zero, CacheItemPriority.Default, callBack)
Next
End Sub
Private Sub DeleteFile(ByVal key As String, ByVal path As Object, ByVal reason As CacheItemRemovedReason)
File.Delete(DirectCast(path, String))
End Sub
Protected Sub RadUpload1_FileExists(sender As Object, e As Telerik.Web.UI.Upload.UploadedFileEventArgs) Handles RadUpload1.FileExists
Dim counter As Integer = 1
Dim file As UploadedFile = e.UploadedFile
Dim targetFolder As String = Server.MapPath(RadUpload1.TargetFolder)
Dim targetFileName As String = Path.Combine(targetFolder, file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension())
While System.IO.File.Exists(targetFileName)
counter += 1
targetFileName = Path.Combine(targetFolder, file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension())
End While
file.SaveAs(targetFileName)
End Sub
End Class