or
Hi all,
Im using radgrid in my application.
I try to get the object of radgrid in pageload at clientside(javascript),but im getting grid as null.
If I try in sample page , I'm able to get the grid.
whats wrong in my code can u please tell me as early as possible. Its urgent for me.
Here is my code.
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function pageLoad() { var grd = $find("<%= grdHistory.ClientID %>");//giving null } </script> </telerik:RadCodeBlock> <form id="form1" runat="server"> <telerik:RadScriptManager ID="scrptMangr1" runat="server" /> <asp:Table ID="tblFilter" runat="server" CssClass="headerTable" Height="70px" width="758px"> <asp:TableRow> <asp:TableCell> <asp:Label ID="begnDatelbl" runat="server" Text="Begin Date:" CssClass="normalLable" /> </asp:TableCell><asp:TableCell> <telerik:RadDateTimePicker ID="begnDate" runat="server" ClientEvents-OnDateSelected="begnDate_DateSelected" Skin="Outlook" Width="165px" Height="12px" CssClass="datetimePicker" > <Calendar runat="server" ID="Calendar1"> <SpecialDays> <telerik:RadCalendarDay Repeatable="Today" ItemStyle-BackColor="Orange" /> </SpecialDays> </Calendar> <DateInput ID="DateInput1" runat="server" DateFormat="MM/dd/yyyy HH:mm:ss" /> <TimeView ID="TimeView1" runat="server" TimeFormat="HH:mm:ss" /> <HideAnimation Type="Slide" /> <ShowAnimation Type="Slide" /> <DatePopupButton ImageUrl="../images/Cal_iconj.gif" HoverImageUrl="../images/Cal_iconj.gif" /> <TimePopupButton ImageUrl="../images/watch.gif" HoverImageUrl="../images/watch.gif" /> </telerik:RadDateTimePicker> </asp:TableCell><asp:TableCell> <asp:Label ID="endDatelbl" runat="server" Text="End Date:" CssClass="normalLable" /> </asp:TableCell><asp:TableCell> <telerik:RadDateTimePicker ID="endDate" runat="server" Skin="Outlook" ClientEvents-OnDateSelected="endPicker_DateSelected" Width="165px" Height="12px" CssClass="datetimePicker" > <Calendar runat="server" ID="Calendar2"> <SpecialDays> <telerik:RadCalendarDay Repeatable="Today" ItemStyle-BackColor="Orange" /> </SpecialDays> </Calendar> <DateInput ID="DateInput2" runat="server" DateFormat="MM/dd/yyyy HH:mm:ss" /> <TimeView ID="TimeView2" runat="server" TimeFormat="HH:mm:ss" /> <HideAnimation Type="Slide" /> <ShowAnimation Type="Slide" /> <DatePopupButton ImageUrl="../images/Cal_iconj.gif" HoverImageUrl="../images/Cal_iconj.gif" /> <TimePopupButton ImageUrl="../images/watch.gif" HoverImageUrl="../images/watch.gif" /> </telerik:RadDateTimePicker> </asp:TableCell><asp:TableCell> <asp:Label ID="serveritylbl" runat="server" Text="Severity:" CssClass="normalLable" /> </asp:TableCell><asp:TableCell> <asp:DropDownList ID="serverityddl" runat="server" CssClass="dropDwnlist" Height="16%" Width="120px"> <asp:ListItem Value="All" Selected="True">Show All</asp:ListItem> <asp:ListItem Value="Low">Low</asp:ListItem> <asp:ListItem Value="Minor">Minor</asp:ListItem> <asp:ListItem Value="Major">Major</asp:ListItem> </asp:DropDownList> </asp:TableCell><asp:TableCell></asp:TableCell></asp:TableRow><asp:TableRow> <asp:TableCell> <asp:Label ID="sourcelbl" runat="server" Text="Source:" CssClass="normalLable" /> </asp:TableCell><asp:TableCell> <asp:DropDownList ID="sourceddl" runat="server" CssClass="dropDwnlist" Width="120px" DataTextField="SourceId" DataValueField="SourceId" AppendDataBoundItems="true" Height="16%"> </asp:DropDownList> </asp:TableCell><asp:TableCell> <asp:Label ID="productNamelbl" runat="server" Text="Product:" CssClass="normalLable" /> </asp:TableCell><asp:TableCell> <asp:DropDownList ID="productddl" runat="server" CssClass="dropDwnlist" DataTextField="ProductName" Width="120px" DataValueField="ProductName" AppendDataBoundItems="true" Height="16%"> <asp:ListItem Value="All" Selected="True">Show All</asp:ListItem> </asp:DropDownList> </asp:TableCell><asp:TableCell> <asp:Label ID="alarmCodelbl" runat="server" Text="Alarm Code:" CssClass="normalLable" /> </asp:TableCell><asp:TableCell> <asp:DropDownList ID="alarmddl" runat="server" CssClass="dropDwnlist" DataTextField="AlarmCode" DataValueField="AlarmCode" AppendDataBoundItems="true" Height="16%" Width="120px"> </asp:DropDownList> </asp:TableCell><asp:TableCell> <asp:ImageButton ID="imgbtnGenerateRpt" runat="server" ImageUrl="~/images/disablebtn.gif" Enabled="false" OnClick="imgbtnGenerateRpt_Click" Width="90px" Height="20px" /> </asp:TableCell></asp:TableRow></asp:Table><div class="line"></div> <asp:Panel ID="pnlExport" runat="server"> <table style="overflow: auto; width:99%; height: 28px;"> <tr> <td style="background-image: url('../images/lblBackGround.gif'); background-repeat: no-repeat; overflow: auto;"> <asp:Label ID="lblHeader" runat="server" Text="Alarm History" CssClass="logReportlbl" /> <asp:ImageButton ID="gridHistoryBtnExcel" ToolTip="Excel" ImageUrl="../images/excel_20x20.png" OnClick="btnExcelHistory_Click" runat="server" Height="16px" /> <asp:ImageButton ID="gridHistoryBtnCsv" ToolTip="Csv" ImageUrl="../images/csv_20x20.png" OnClick="btnCSVHistory_Click" runat="server" Height="16px" /> <asp:ImageButton ID="btnPrintHistory" ImageUrl="../images/PrintBlue.PNG" OnClick="btnPrintHistory_Click" ToolTip="Print" runat="server" /> <asp:ImageButton ID="gridHistoryBtnHelp" ToolTip="Help" ImageUrl="../images/help_20x20.png" runat="server" Height="16px" OnClientClick="window.open('//Help/ApplicationHelp.htm');" /> </td> <td style="text-align:right;"> <asp:Label ID="dateLbl" runat="server" CssClass="italicLbl"/> </td> </tr> <tr> <td colspan="2" style="text-align:right;"> <asp:Label ID="filterLbl" runat="server" Text="Source:All,Product:All,Alarm Code:All,Severity:All" CssClass="italicLbl"/> </td> </tr> </table> </asp:Panel> <asp:Timer ID="refrshTimer" runat="server" OnTick="refrshTimer_Tick" /> <asp:Panel ID="pnlAlarmSummaryVisibility" runat="server"> <div class="line" style=" margin-top:5px;"></div> <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" loadingpanelid="LoadingPanel1"> <telerik:RadGrid ID="grdHistory" Style="border: 0" runat="server" AllowSorting="true" Width="98%" PageSize="5" AllowPaging="true" CssClass="gridView1" AutoGenerateColumns="false" OnItemDataBound="grdHistory_DataBound" OnNeedDataSource="grdHistory_NeedDataSource" OnItemCommand="grdHistory_ItemCommand" OnSortCommand="grdHistory_SortCommand" OnExcelMLExportRowCreated="grdHistory_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="grdHistory_ExcelMLExportStylesCreated"> <SortingSettings EnableSkinSortStyles="false" /> <MasterTableView TableLayout="Fixed" AllowMultiColumnSorting="false" ShowHeadersWhenNoRecords="false"> <ItemStyle CssClass="rgRow" Font-Names="Arial" Font-Size="12px" ForeColor="#000000"/> <AlternatingItemStyle Font-Names="Arial" Font-Size="12px" ForeColor="#000000"/> <HeaderStyle CssClass="actLogGrdheader" /> <ItemStyle /> <PagerStyle Mode="NumericPages" /> <Columns> <telerik:GridBoundColumn DataField="SetDateTime" SortExpression="SetDateTime" HeaderText="Date/Time" HeaderStyle-Width="70px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Status" SortExpression="Status" HeaderText="Incident" ItemStyle-Width="50px" HeaderStyle-Width="50px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="SourceId" SortExpression="SourceId" HeaderText="Source" ItemStyle-Width="80px" HeaderStyle-Width="80px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ProductName" SortExpression="ProductName" HeaderText="Product" ItemStyle-Width="80px" HeaderStyle-Width="80px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="AlarmInfo" SortExpression="AlarmInfo" HeaderText="Description" UniqueName="AlarmInfo" ItemStyle-Width="260px" HeaderStyle-Width="260px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Severity" SortExpression="Severity" HeaderText="Severity" ItemStyle-Width="60px" HeaderStyle-Width="60px"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="AlarmDateTime" Visible="false"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings> <%-- <Scrolling AllowScroll="True" ScrollHeight="100px" UseStaticHeaders="True" SaveScrollPosition="True" > </Scrolling>--%> </ClientSettings> </telerik:RadGrid> </telerik:RadAjaxPanel> <div class="line" style="margin-top: -2px"></div> </asp:Panel> <asp:Label ID="norecMsgLbl" runat="server" ForeColor="#153b77" Font-Size="15" Font-Names="Arial" style="position:relative; top:150px; left:25%; right:40%;" /> <%--</ContentTemplate> </asp:UpdatePanel>--%> <telerik:RadAjaxLoadingPanel id="LoadingPanel1" runat="server" > <asp:Image ID="img" runat="server" ImageUrl="~/images/loading3.gif" BackColor="Beige" AlternateText="Loading" Style="top: 100px; left: 307px; position: absolute; height: 17px; width: 67px" /> </telerik:RadAjaxLoadingPanel> <asp:Label runat="server" ID="lblError" ForeColor="Red" Font-Bold="true" Font-Size="12px" Font-Names="Arial"></asp:Label><p> </p><telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" Skin="Telerik" Animation="None" Position="BottomRight" EnableShadow="true" AutoTooltipify="true"> </telerik:RadToolTipManager> </form></body></html><telerik:RadToolBar ID="RadToolBar4" runat="server" Width="100.3%" OnClientLoad="clientLoad" Skin="Black" CssClass="SeparatedButtons" onbuttonclick="RadToolBar4_ButtonClick"> <Items> <telerik:RadToolBarButton CommandName="Documents" ID="rbDocuments" runat="server" Text="Documents" Font-Names="Microsoft Sans Serif" Font-Size="Medium"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Text="View Account Profile" Font-Size="Medium" CheckOnClick="true" CommandName="ViewAccountProfile"> </telerik:RadToolBarButton> <telerik:RadToolBarDropDown runat="server" Text="Drop down" CssClass="rightAligned" Font-Size="Medium"> <Buttons> <telerik:RadToolBarButton runat="server" Text="Sign Out" Font-Size="Medium" CheckOnClick="true" CommandName="SignOut"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Text="Contact Us" Font-Size="Medium" CheckOnClick="true" CommandName="ContactUs"> </telerik:RadToolBarButton> </Buttons> </telerik:RadToolBarDropDown> <telerik:RadToolBarButton runat="server" Text="Sign Out" Font-Size="Medium" CheckOnClick="true" CommandName="SignOut" CssClass="rightAligned"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Text="Contact Us" Font-Size="Medium" CheckOnClick="true" CommandName="ContactUs" CssClass="rightAligned"> </telerik:RadToolBarButton> <telerik:RadToolBarButton runat="server" Text="Create Account Profile" Font-Size="Medium" CheckOnClick="true" CommandName="AccountProfile" CssClass="rightAligned"> </telerik:RadToolBarButton> </Items> </telerik:RadToolBar>private void createRadGrid() { //create radgrid RadGrid rg = new RadGrid(); rg.ID = "RadGridView"; //setting the datasource and itemcommand event handler. rg.DataSourceID = "MachineDataSet"; rg.ItemCommand += new GridCommandEventHandler(RadGridView_ItemCommand); rg.Width = 862; rg.CellSpacing = 2; rg.CellPadding = 4; rg.BorderWidth = 3; rg.BackColor = System.Drawing.Color.Transparent; rg.BorderColor = System.Drawing.Color.DarkGray; rg.ForeColor = System.Drawing.Color.Black; rg.ItemStyle.HorizontalAlign = HorizontalAlign.Center; rg.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; rg.BorderStyle = BorderStyle.Ridge; rg.ShowStatusBar = true; rg.AllowPaging = true; rg.PageSize = 5; rg.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; rg.AutoGenerateColumns = false; rg.MasterTableView.PageSize = 5; rg.MasterTableView.DataKeyNames = new string[] { "ID" }; rg.MasterTableView.ClientDataKeyNames = new string[] { "ID" }; rg.MasterTableView.AutoGenerateColumns = false; rg.ClientSettings.Resizing.AllowColumnResize = true; rg.ClientSettings.Resizing.EnableRealTimeResize = true; rg.ClientSettings.Resizing.ResizeGridOnColumnResize = true; GridBoundColumn boundColumn = new GridBoundColumn(); boundColumn.DataField = "ID"; boundColumn.HeaderText = "ID"; boundColumn.UniqueName = "MachineID"; boundColumn.Visible = false; rg.MasterTableView.Columns.Add(boundColumn); GridBoundColumn boundColumn1 = new GridBoundColumn(); boundColumn1.DataField = "SiteName"; boundColumn1.HeaderText ="Site Name"; boundColumn1.Resizable = true; boundColumn1.ReadOnly = true; rg.MasterTableView.Columns.Add(boundColumn1); GridBoundColumn boundColumn2 = new GridBoundColumn(); boundColumn2.DataField = "Name"; boundColumn2.HeaderText = "Machine Name"; boundColumn2.Resizable = true; boundColumn2.ReadOnly = true; rg.MasterTableView.Columns.Add(boundColumn2); GridBoundColumn boundColumn3 = new GridBoundColumn(); boundColumn3.DataField = "MachineType"; boundColumn3.HeaderText = "Machine Type"; boundColumn3.Resizable = true; boundColumn3.ReadOnly = true; rg.MasterTableView.Columns.Add(boundColumn3); GridBoundColumn boundColumn4 = new GridBoundColumn(); boundColumn4.DataField = "MachineModel"; boundColumn4.HeaderText = "Machine Model"; boundColumn4.Resizable = true; boundColumn4.ReadOnly = true; rg.MasterTableView.Columns.Add(boundColumn4); GridButtonColumn buttonColumn = new GridButtonColumn(); buttonColumn.ButtonType = GridButtonColumnType.PushButton; buttonColumn.CommandName = "AssignNewValues"; buttonColumn.Resizable = true; buttonColumn.Text = "Assign New Values"; rg.MasterTableView.Columns.Add(buttonColumn); PlaceHolder_RadGridView.Controls.Add(rg); }<telerik:RadComboBox ID="cboCust" Runat="server" Width="178px" DropDownWidth="500px" HighlightTemplatedItems="True" EmptyMessage="Select Customer" EnableLoadOnDemand="True" Filter="Contains" Height="250px" MarkFirstMatch="True" AutoPostBack="True"> <HeaderTemplate> <table style="width:415px; text-align:left"> <td style="width:50px;">ID</td> <td style="width:200px;">Name</td> <td style="width:200px;">Address</td> </table> </HeaderTemplate> <ItemTemplate> <table style="width:415px; text-align:left"> <td style="width:50px;"> <%# DataBinder.Eval(Container.DataItem, "ID")%> </td> <td style="width:200px;"> <%# DataBinder.Eval(Container.DataItem, "Name")%> </td> <td style="width:200px;"> <%# DataBinder.Eval(Container.DataItem, "Address")%> </td> </table> </ItemTemplate></telerik:RadComboBox>Protected Sub cboCust_ItemsRequested(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles cboCust.ItemsRequested cSQL = "SELECT * FROM Customer" With cboCust .DataSource = FillDataset(cSQL) .DataTextField = "ID" .DataValueField = "ID" .DataBind() End WithEnd SubProtected Sub btnCheck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCheck.Click If cboCust.SelectedValue = "" Then lblMsg.Text = "Not item in list" Else lblMsg.Text = "Item in list" End IfEnd Sub
<table> <tr> <td> <telerik:RadListBox ID="countiesRLB" runat="server" DataKeyField="county_name" AllowTransfer="true" TransferToID="selectedcountiesRLB" AllowTransferOnDoubleClick="true" DataSortField="county_name" DataTextField="county_name" DataValueField="county_name" Height="200px" Width="175px" Visible="false" SelectionMode="Multiple" Sort="Ascending" ontransferred="countiesRLB_Transferred" AutoPostBackOnTransfer="true"> <HeaderTemplate> Counties</HeaderTemplate> </telerik:RadListBox> </td> <td> <telerik:RadListBox ID="selectedcountiesRLB" runat="server" Height="200px" Width="150px" Visible="false" SelectionMode="Multiple"> <HeaderTemplate> Selected Counties</HeaderTemplate> </telerik:RadListBox> </td> </tr></table>[ServiceContract] public interface IACT { [OperationContract] RadComboBoxData GetCustomerOrderHistoryTelerik(RadComboBoxContext context); }
[BasicHttpBindingServiceMetadataExchangeEndpoint] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] public class ACT : IACT { public RadComboBoxData GetCustomerOrderHistoryTelerik(RadComboBoxContext context) { //The RadComboBoxData object contains all required information for load on demand: // - the items // - are there more items in case of paging // - status message to be displayed (which is optional) RadComboBoxData result = new RadComboBoxData();
...
<%@ ServiceHost Language="C#" Debug="true" Service="ACT, $SharePoint.Project.AssemblyFullName$" CodeBehind="ACT.svc.cs" Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<telerik:RadComboBox runat="server" ID="RadComboBox1" Height="100px" AllowCustomText="true" LoadingMessage="Loading, please wait..." EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true" EmptyMessage="Type here ..." ItemsPerRequest="10"> <WebServiceSettings Path="~/_layouts/Sample/Services/ACT.svc" Method="GetCustomerOrderHistoryTelerik" /> </telerik:RadComboBox>
<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> </system.serviceModel>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DemoDummyControl.ascx.cs" Inherits="X.DemoDummyControl" %><p>Dummy Control</p><p>To test RadWindow</p><p> <asp:Button runat="server" ID="test" OnClick="Click" /></p><%@ Page Title="" Language="C#" MasterPageFile="~/Popup.Master" AutoEventWireup="true" CodeBehind="demo.aspx.cs" Inherits="X.demo" %><%@ Register Src="~/DemoDummyControl.ascx" TagName="Dummy" TagPrefix="uc" %><asp:Content ID="Content1" ContentPlaceHolderID="Scripts" runat="server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"><p><uc:DemoDummyControl runat="server" /></p></asp:Content>