Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
203 views
I'm trying to create a radgrid dynamically and bind it to a dynamically created ObjectDataSource, but grid is always empty (maxRows is 0 in GetData method).  What did I do  wrong?

Next question is this._grid.DataBind() in OnLoad method. Is it necessary? After it grid will show data, but paging will not work (other pages will by empty).

Standard GridView seems to be working correctly.

Here is full sources

using System;
using System.ComponentModel;
using System.Data;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;
using Oracle.DataAccess.Client;
using Parus.Core;
using Telerik.Web.UI;
 
namespace WebDesigner
{
    public partial class WebForm1 : Page
    {
        private RadGrid _grid;
        private GridView _grid2;
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this._grid = CreateGrid();
            this.GridPlaceHolder.Controls.Add(this._grid);
            this._grid2 = CreateGrid2();
            this.GridPlaceHolder.Controls.Add(this._grid2);
        }
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            RadAjaxManager.AjaxSettings.AddAjaxSetting(this._grid, this._grid);
            RadAjaxManager.AjaxSettings.AddAjaxSetting(this._grid2, this._grid2);
            //_grid.DataBind();
            _grid2.DataBind();
        }
 
        private static RadGrid CreateGrid()
        {
            var grid = new RadGrid
                           {
                               Width = new Unit(100, UnitType.Percentage),
                               ID = "grid_test",
                               Skin = "Windows7",
                               PageSize = 10,
                               AllowPaging = true,
                               AutoGenerateColumns = false,
                               GroupingEnabled = false,
                               ShowGroupPanel = false,
                           };
            grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
            grid.PagerStyle.AlwaysVisible = true;
            grid.NeedDataSource += Grid_NeedDataSource;
 
            grid.MasterTableView.Width = new Unit(100, UnitType.Percentage);
            grid.MasterTableView.PageSize = grid.PageSize;
            grid.MasterTableView.AllowPaging = grid.AllowPaging;
            grid.MasterTableView.PagerStyle.Mode = grid.PagerStyle.Mode;
            grid.MasterTableView.PagerStyle.AlwaysVisible = grid.PagerStyle.AlwaysVisible;
            grid.MasterTableView.AutoGenerateColumns = grid.AutoGenerateColumns;
 
            var gridColumn = new GridBoundColumn();
            gridColumn.DataField = "NRN";
            gridColumn.HeaderText = "Ident";
            grid.MasterTableView.Columns.Add(gridColumn);
 
            gridColumn = new GridBoundColumn();
            gridColumn.DataField = "SCODE";
            gridColumn.HeaderText = "Caption";
            grid.MasterTableView.Columns.Add(gridColumn);
 
            return grid;
        }
 
        private GridView CreateGrid2()
        {
            var grid = new GridView
                           {
                               Width = new Unit(100, UnitType.Percentage),
                               ID = "grid_test2",
                               PageSize = 10,
                               AllowPaging = true,
                               AutoGenerateColumns = false,
                               DataSource = new MyDataSource(typeof(CustomDataProxy))
                           };
 
            grid.PageIndexChanging += Grid2_PageIndexChanging;
 
            var gridColumn = new BoundField();
            gridColumn.DataField = "NRN";
            gridColumn.HeaderText = "Ident";
            grid.Columns.Add(gridColumn);
 
            gridColumn = new BoundField();
            gridColumn.DataField = "SCODE";
            gridColumn.HeaderText = "Caption";
            grid.Columns.Add(gridColumn);
 
            return grid;
 
        }
 
        private void Grid2_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this._grid2.PageIndex = e.NewPageIndex;
            this._grid2.DataBind();
        }
 
        private static void Grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var grid = sender as RadGrid;
            grid.DataSource = new MyDataSource(typeof(CustomDataProxy));
        }
    }
 
    #region MyObjectDataSource
 
    [DataObject]
    public class MyDataSource : ObjectDataSource
    {
        public MyDataSource(Type type)
        {
            this.DataProxy = type;
            TypeName = type.FullName;
            SelectCountMethod = "GetTotalRowsCount";
            SelectMethod = "GetData";
            EnablePaging = true;
            MaximumRowsParameterName = "maxRows";
            StartRowIndexParameterName = "firstRow";
            SortParameterName = "orderFields";
            ObjectCreating += OnObjectCreating;
        }
 
        private Type DataProxy
        {
            get;
            set;
        }
 
        private void OnObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = Activator.CreateInstance(DataProxy, new[] { "V_WEBTEST_CODE" });
        }
    }
 
    #endregion
 
    #region Custom DataObject
 
    public class CustomDataProxy : BaseDataProxy
    {
        private readonly string _tableName;
        public CustomDataProxy(string tableName)
        {
            this._tableName = tableName;
        }
 
 
        public override string TableName
        {
            get
            {
                return this._tableName;
            }
        }
    }
 
    [DataObject]
    public abstract class BaseDataProxy
    {
        private const string CCountQuery = "select count(*) from {0}";
        private const string CSelectTemplate = "select * from {0}";
        private const string COrderTemplate = " order by {0}";
        private const string CPagingQuery = "select * from (select rownum rownum#, T.* from ({0}) T) where rownum# between :StartRow and :EndRow";
 
        abstract public string TableName
        {
            get;
        }
 
        public int GetTotalRowsCount()
        {
            using (var connection = Dispatcher.Instance.CreateConnection())
            {
                var queryText = string.Format(CCountQuery, this.TableName);
                using (var query = new OracleCommand(queryText, connection)
                                       {
                                           CommandType = CommandType.Text
                                       })
                {
                    var result = query.ExecuteScalar();
                    return result != null ? Convert.ToInt32(result, CultureInfo.CurrentCulture) : 0;
                }
            }
        }
 
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public DataTable GetData(int firstRow, int maxRows, string orderFields)
        {
            using (var connection = Dispatcher.Instance.CreateConnection())
            {
                var queryText = string.Format(CSelectTemplate, this.TableName);
                if (!string.IsNullOrEmpty(orderFields))
                {
                    queryText += string.Format(COrderTemplate, orderFields);
                }
 
                queryText = string.Format(CPagingQuery, queryText);
 
                var query = new OracleCommand(queryText, connection)
                {
                    CommandType = CommandType.Text
                };
 
                query.Parameters.Add(@"StartRow", firstRow + 1);
                query.Parameters.Add(@"EndRow", firstRow + maxRows);
 
                using (var a = new OracleDataAdapter(query))
                {
                    var dt = new DataTable
                    {
                        Locale = CultureInfo.CurrentCulture
                    };
 
                    a.Fill(dt);
                    return dt;
                }
            }
        }
    }
 
    #endregion
}

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebDesigner.WebForm1" %>
 
<%@ 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">
<head runat="server">
  <title></title>
</head>
<body>
  <form id="form1" runat="server">
  <telerik:RadScriptManager ID="RadScriptManager" runat="server">
  </telerik:RadScriptManager>
  <asp:PlaceHolder ID="GridPlaceHolder" runat="server"></asp:PlaceHolder>
  <telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
  </telerik:RadAjaxManager>
  </form>
</body>
</html>
alex lexx
Top achievements
Rank 1
 answered on 03 Feb 2011
1 answer
105 views
Hi Telerik,

I have a dynamically created Dock and its content is a chart. I load the content for the dock like so:

private void LoadDockContent(RadDock dock)
{
    System.Web.UI.Control ctrl = Page.LoadControl("PowerUsage.ascx");
    dock.ContentContainer.Controls.Add(ctrl);
}

I need to be able to access the name of the control ClientSide.

I suspect it's something like this, but I'm not quite on:

<script type="text/javascript">
    function OnClientInitialize(dock, args) {
        var content = dock.get_contentContainer();
        var control = $telerik.isIE ? content.childNodes[0].innerHTML : content.childNodes[1].innerHTML;
        alert(control);
    }
</script>

The alert displays a dump of all the HTML in the dock. This does include the control I am looking for, but there would be some extremely heavy parsing necessary to isolate the string that I want from the HTML. I've attached to this post "html.png" which is the output of the alert.

If I could just get the img id instead of all the HTML I would be happier, but I would be happiest if I could capture the control name without any parsing, obviously. Ultimately, my goal is to utilize some jQuery to resize the chart control stored on the RadDock. Just to make sure I'm not headed down a dark path, I would also just like to get a quick, "Yep. That should work!" from you guys.

<script type="text/javascript">
    jQuery(function($) {
            $(window).wresize(SetPageChartSizes<%= Chart.ClientID %>);
            SetPageChartSizes<%= Chart.ClientID %>();
        });
                 
        function SetPageChartSizes<%= Chart.ClientID %>() {
            document.getElementById('<%= hfChartWidth.ClientID %>').value = (document.getElementById('<%= updatePanel.ClientID %>').offsetWidth - 4);
            <%=Page.GetPostBackEventReference(btnHidden_Charts)%>;
    }
</script>

So, this code isn't 100% relevant to what I've got going on, yet. This function waits for the window to be resized and then resizes Chart based on the new window size. I am going to rewrite this so that whenever the size of the Dock changes the content it controls (a chart) will resize to fill the size of the dock. Chart doesn't just exist on the page, though. I have to get a handle on that -- which means I need to get the control name from the Dock.

Let me know if anything here is unclear.

Thanks,

Sean
Pero
Telerik team
 answered on 03 Feb 2011
1 answer
77 views
Hi Team,

i have the below code for enabling the VirtualScrollPaging on grid. this is working fine on Mozilla. but on IE 7 (not checked on other IE version) when i am scrolling it jumping the scroll to 20-40 pages. here i noticed one thing is that the scroll bar size is diffrent in both MOzilla and IE 7. i had attached the screen shots with mail.

Code :
<telerik:RadGrid CssClass="RadGrid" GridLines="None" BorderStyle="None" ID="grdNominationDetails"
                        Width="100%" runat="server" AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
                        alternatingrowstyle-cssclass="alternate" OnDeleteCommand="grdNominationDetails_RowDeleting"
                        OnSortCommand="grdNominationDetails_Sorting" OnItemDataBound="grdNominationDetails_RowDataBound" PageSize="20">
                        <PagerStyle Mode="NumericPages" PageButtonCount="20" AlwaysVisible="true" />
                        
                        <%--<EmptyDataTemplate>
                                            <center>
                                                <asp:Label ID="lblNoNominationsMessage" CssClass="error-message" runat="server" Text="Nomination Data not available.<br>Please click 'Import HIPO Nomination Data' to upload nomination data."></asp:Label>
                                            </center>
                                        </EmptyDataTemplate>--%>
                        <MasterTableView AllowNaturalSort="true" >
                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="Nominated" ItemStyle-HorizontalAlign="Center"
                                    SortExpression="PMConfirmation" HeaderStyle-Width="14%" >
                                    <ItemTemplate>
                                        <div style="text-align: center;">
                                            <asp:CheckBox ID="chkPMConfirmation" runat="server" Checked='<%# ConvertNominationStatusToBool(Eval("PMConfirmation") as bool?) %>' />
                                        </div>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Employee Name" HeaderStyle-Width="30%"
                                    SortExpression="LastName">
                                    <ItemTemplate>
                                        <a href="../../Develop/CandidateProfile.aspx?uid=<%# GetUserId( Eval("UserId")) %>">
                                            <%# FormatName(Eval("FirstName"),Eval("LastName"))%>
                                        </a>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Nominator Name" HeaderStyle-Width="28%"
                                    SortExpression="NominatorLastName">
                                    <ItemTemplate>
                                        <div class="wordwrap">
                                            <asp:Literal ID="ltlNominatorName" runat="server" Text='<%# FormatName(Eval("NominatorFirstName"), Eval("NominatorLastName")) %>'></asp:Literal>
                                        </div>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Status" ItemStyle-HorizontalAlign="Center"
                                    HeaderStyle-Width="20%"  SortExpression="Nominated">
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlNominationStatus" runat="server">
                                        </asp:DropDownList>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderStyle-Width="8%"  HeaderText="Edit">
                                    <ItemTemplate>
                                        <div style="text-align: center;">
                                            <asp:ImageButton ToolTip="Delete" OnClientClick="ShowModal(this,'HIPO Candidate Delete Warning','Are you sure you want to delete this HIPO candidate?');return false;"
                                                ID="imgDelete" ImageUrl="~/images/icon_delete_competency.gif" runat="server"
                                                CausesValidation="false" CommandName="Delete" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "UserId") %>'
                                                Text="Delete"></asp:ImageButton>
                                        </div>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings EnableRowHoverStyle="true" EnableAlternatingItems="true">
                            
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" EnableVirtualScrollPaging="true">
                            </Scrolling>
                        </ClientSettings>
                    </telerik:RadGrid>
Tsvetina
Telerik team
 answered on 03 Feb 2011
1 answer
87 views
Hi,

I'm using the example posted on the following link
http://demos.telerik.com/aspnet-ajax/tooltip/examples/tooltipcalendar/defaultcs.aspx


When I try to click on a date associated with a tooltip in IE8 (8.0.6001.18702), I get an unknown runtime error in ScriptResource.axd
The page works fine in Firefox, Chrome and Opera..

Any Ideas??

Source Code for page containing the calendar
public partial class rcalendar : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {    }
    protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
    {
        int ID = e.Day.Date.Day;
         if (ID == 3 || ID == 5 || ID == 14)
        {
            TableCell cell = e.Cell;
            cell.Attributes.Add("onclick", "ShowToolTip(this);");
            cell.Attributes.Add("id", "Calendar_" + ID.ToString());
        }
     }
    protected void RadToolTipManager1_AjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)
    {
        CalendarTT cdrTTobj = (CalendarTT)this.LoadControl("CalendarTT.ascx");
         cdrTTobj.Dateid = int.Parse(e.Value);
        cdrTTobj.ID = Guid.NewGuid().ToString();
         e.UpdatePanel.ContentTemplateContainer.Controls.Add(cdrTTobj);
    }
}

aspx page for calendar
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="rcalendar.aspx.cs" Inherits="CdrApp.rcalendar" %>
<%@ Register Src="CalendarTT.ascx" TagName="CalendarTT" TagPrefix="uc1" %>
<%@ 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">
 
<head runat="server">
    <title></title>
    <style type="text/css">
 
         
 
    .RadCalendar .rcRow td
    {
        text-align: center !important;
        vertical-align: middle !important;
        width: 50px;
    }
 
 
</style>
</head>
<body style="height: 462px">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
 
        function ShowToolTip(sender) {
            var tooltipManager = $find("<%=RadToolTipManager1.ClientID %>");
 
            //If the user hovers the image before the page has loaded, there is no manager created
            if (!tooltipManager) return;
 
            //Find the tooltip for this element if it has been created
            var tooltip = tooltipManager.getToolTipByElement(sender);
 
            //Create a tooltip if no tooltip exists for such element
            if (!tooltip) {
                tooltip = tooltipManager.createToolTip(sender);
                var longValue = sender.getAttribute("ID");
                var neededValue = longValue.substring(longValue.indexOf('_') + 1)
                tooltip.set_value(neededValue);
                tooltip.show();
            }
        }
 
        </script>
     
    </telerik:RadCodeBlock>
 
    <div>
     
                <telerik:RadCalendar ID="RadCalendar1" Runat="server" DayNameFormat="Full"
                    EnableMultiSelect="False" Height="300px" SelectedDate="" TitleAlign="Center"
                    ViewSelectorText="x" Width="300px" PresentationType="Preview"
                    ShowRowHeaders="False"
                    ondayrender="RadCalendar1_DayRender">
                    </telerik:RadCalendar>
                    <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"
        onajaxupdate="RadToolTipManager1_AjaxUpdate" Animation="Fade"
        AutoCloseDelay="30000" EnableShadow="True" EnableTheming="True"
        HideEvent="LeaveTargetAndToolTip" ShowEvent="OnClick" BorderStyle="Outset"
        Position="Center">
    </telerik:RadToolTipManager>
    </div>
    </form>
</body>
</html>




Thanks..
Ron
Top achievements
Rank 1
 answered on 03 Feb 2011
2 answers
269 views
I am trying to updated a RadGrid based on what is selected in a RadComboBox but the grid displays nothing.  The Grid's SQL DataSource is tied to a stored procedure which accepts a parameter (CustBill) from the RadComboBox.  Ajax Manager is setup to update both the RadGrid and RadComboBox but the stored procedure returns 0 results no matter what is selected in the combo box.  Here is the AjaxManager, RadComboBox, and SQL Datasource code.  Is AjaxManager refreshing the controls properly?  Your help is appreciated. 
-Scott

 

 

***
<
telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"

 

 

 

DefaultLoadingPanelID="RadAjaxLoadingPanel1">

 

 

 

  <AjaxSettings>

 

 

 

  <telerik:AjaxSetting AjaxControlID="RadComboBox1">

 

 

 

    <UpdatedControls>

 

 

 

        <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />

 

 

 

        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />

 

 

 

    </UpdatedControls>

 

 

 

</telerik:AjaxSetting>

 

 

 

</AjaxSettings>

 

 

 

</telerik:RadAjaxManager>



***
<telerik:RadComboBox ID="RadComboBox1" Runat="server"

 

 

 

    DataSourceID="SqlDataSource1" DataTextField="CustBill"

 

 

 

    DataValueField="CustBill" Height="122px" Skin="Windows7" Width="319px">

 

 

 

 

 

 

 

    <Items>

 

 

 

 

 

 

 

        <telerik:RadComboBoxItem Text="All" Value="0" Selected="true" />

 

 

 

 

 

 

 

    </Items>

 

 

 

 

 

 

 

</telerik:RadComboBox>

 

 

 

 


*** This SQL Data Source populates the combo box ***

 

<

 

 

asp:SqlDataSource ID="SqlDataSource1" runat="server"

 

 

 

    ConnectionString="<%$ ConnectionStrings:crmDashboardConnectionString %>"

 

 

 

    SelectCommand="SELECT TOP (10) CustBill FROM crmSalesSuperior WHERE (CustBill IN (SELECT CustBill FROM crmSalesSuperior AS crmSalesSuperior_1 WHERE (Branch = 102))) GROUP BY CustBill ORDER BY CustBill">

 

 

 

 

</asp:SqlDataSource>

 

 

 

 



*** This is the Grid's SQL data source, calling a stored procedure with a parameter from combo box. ***

 

 

 

 

<asp:SqlDataSource ID="SqlDataSource2" runat="server"

 

 

 

ConnectionString="<%$ ConnectionStrings:crmDashboardConnectionString %>"

 

 

 

SelectCommand="CRMDashboardSales" SelectCommandType="StoredProcedure">

 

 

 

 

    <SelectParameters>

 

 

 

 

        <asp:ControlParameter Name="CustBill" ControlID="RadComboBox1"

 

 

 

            PropertyName="SelectedValue" Type="String"

 

 

 

            DefaultValue="Power Equipment Co " />

 

 

 

 

    </SelectParameters>

 

 

 

 

</asp:SqlDataSource>

 

 

 

 




 

Scott
Top achievements
Rank 1
 answered on 03 Feb 2011
3 answers
101 views
I am using the Q3 2008 controls currently.

I have a radWindow I am opneing and setting options via JavaScript:

 

 

 

function openWindow() {  
        window.setTimeout(function() {  
            var oManager = GetRadWindowManager();  
            var rdWin = oManager.open('<%=WindowURL%> ''rwVideoTutorial');  
            rdWin.set_status('Video Tutorial <%=HelpVideoID %> ');  
            rdWin.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move);  
            rdWin.center;  
            rdWin.remove_resize;  
            rdWin.add_dragEnd(OnClientDragEnd);  
            rdWin.setSize(620, 430);  
        }, 1000);  
    }  
 
    function OnClientDragEnd(sender, eventArgs) {  
        var oManager = GetRadWindowManager();  
        var oWnd = oManager.getWindowById(sender.get_id());  
                oWnd.reload();  
 
          
    } 

I am embeding a YouTube video on a page that is loaded by the RadWindow. In IE8 some strange things are happening. I added the OnClinetDragEnd in hopes that the content would reload, but it doesn't in IE8 unless I have IE8 in compatability mode. If hte winodw is draged in IE8 the audio cuts out fromt he video, so I thought I could jsut reload the content. Also, when the window closes and the video is still running, you can still hear the audio after the window is clsoed. I am not experiencing any of these issues with FireFox. 

Ultimately, I would like the content to reload as it does in FireFox, but in FireFox I really don't need to reload the content, because even after the window is done being dragged the video plays from where it left off.

If I can;t get this to work IN IE8 like it does in FF, how can I set the window to be destroyed via Javascript? I have the window set to be destroyed in the ASPX code, but I guess, since I am openeing it via javascript that doesn't matter.

Daniel

 

 

Georgi Tunev
Telerik team
 answered on 03 Feb 2011
4 answers
148 views
Hello,

I have a web site that has a radmenu at the top of the page, with a radtabstrip directly below it, then a radwindow(s) below that.  I'm using the tabstrip and radwindows to simulate tabs with different web pages, much like IE and other browsers do only this is all within my web site.  I am having an issue with the latest build where the radmenu is showing behind the radwindows.  Previously this worked fine - I had the z-index on the radmenu set to a large number and the menu would always show on top.  When I upgraded to the latest build, the radmenu shows above the tabstrip but below the radwindow.  I've tried setting the z-index of the radmenu to something insanely high and also tried setting the z-index to a low value on my radwindowmanager.  Neither seem to work, the radmenu always shows behind the radwindow.  Is this a bug with the latest build, or is there something new that I need to account for in my page?  I downgraded to the previous build and verified this works fine.  It's just the latest build that seems to act differently.

Thanks!
Richard
Richard
Top achievements
Rank 1
 answered on 03 Feb 2011
1 answer
58 views
Hello,

I'm trying to implement the Tooltipified RadGrid in my web user control.  I've followed all the instructions  according to your attached file telerikradtooltipsample.zip. I'm also using this example: http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx
I'm working on DotNetNuke and the following exception appears.
Error: TestToolTip is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
My code snippets:

TestToolTip.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestToolTip.ascx.cs" Inherits="SU_SaleStatisticImport.TestToolTip" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="Telerik" %>
<%@ Register Src="ActivityDetails.ascx" TagName="ActivityDetails" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server">
    </asp:ScriptManager>
    <Telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
    </Telerik:RadAjaxLoadingPanel>
    <Telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
        Width="250" Height="350" runat="server" EnableShadow="true" OnAjaxUpdate="OnAjaxUpdate"
        RelativeTo="Element" Position="MiddleRight">
    </Telerik:RadToolTipManager>
    <Telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <Telerik:AjaxSetting AjaxControlID="rgCampaigns">
                <UpdatedControls>
                    <Telerik:AjaxUpdatedControl ControlID="rgCampaigns" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <Telerik:AjaxUpdatedControl ControlID="RadToolTipManager1" />
                </UpdatedControls>
            </Telerik:AjaxSetting>
        </AjaxSettings>
    </Telerik:RadAjaxManager>
    <Telerik:RadGrid ID="rgCampaigns" runat="server" OnItemDataBound="rgCampaigns_ItemDataBound"
        AutoGenerateColumns="false">
        <MasterTableView runat="server" DataKeyNames="GlobalCode">
            <Columns>
                <Telerik:GridTemplateColumn HeaderText="First">
                    <ItemTemplate>
                        <asp:Label ID="lblTitle" runat="server" Text="Show ToolTip"></asp:Label>
                    </ItemTemplate>
                </Telerik:GridTemplateColumn>
                <Telerik:GridBoundColumn DataField="SecondColumn" HeaderText="Second">
                </Telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </Telerik:RadGrid>
    </form>
</body>
</html>

TestToolTip.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
namespace SU_SaleStatisticImport
{
    public partial class TestToolTip : System.Web.UI.UserControl
    {
        protected System.Data.DataTable GetData()
        {
            System.Data.DataTable tbl = new System.Data.DataTable();
            tbl.Columns.Add(new System.Data.DataColumn("GlobalCode"));
            tbl.Columns.Add(new System.Data.DataColumn("SecondColumn"));
            tbl.Columns.Add(new System.Data.DataColumn("ThirdColumn"));
            tbl.Columns.Add(new System.Data.DataColumn("FourthColumn"));
            tbl.Rows.Add(new object[] { "firstRecord1", "firstRecord2", "firstRecord3", "firstRecord4" });
            tbl.Rows.Add(new object[] { "secondRecord1", "secondRecord2", "secondRecord3", "secondRecord4" });
            tbl.Rows.Add(new object[] { "thirdRecord1", "thirdRecord2", "thirdRecord3", "thirdRecord4" });
            return tbl;
 
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                rgCampaigns.DataSource = GetData();
                rgCampaigns.DataBind();
            }
        }
 
        protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
        {
            this.UpdateToolTip(args.Value, args.UpdatePanel);
        }
        private void UpdateToolTip(string ActivityCode, UpdatePanel panel)
        {
            Control ctrl = Page.LoadControl("~/ActivityDetails.ascx");
            panel.ContentTemplateContainer.Controls.Add(ctrl);
 
            ActivityDetails details = (ActivityDetails)ctrl;
            details.ActivityCode = ActivityCode;
 
        }
 
        protected void rgCampaigns_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
 
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                Control target = e.Item.FindControl("lblTitle");
                if (!Object.Equals(target, null))
                {
                    if (!Object.Equals(this.RadToolTipManager1, null))
                    {
                        //Add the button (target) id to the tooltip manager
                        this.RadToolTipManager1.TargetControls.Add(target.ClientID, (e.Item as GridDataItem).GetDataKeyValue("GlobalCode").ToString(), true);
 
                    }
                }
            }
 
 
        }
    }
}

ActivityDetails.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ActivityDetails.ascx.cs" Inherits="SU_SaleStatisticImport.ActivityDetails" %>
<asp:label id="lbltest" runat="server" text="Label"></asp:label>

ActivityDetails.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace SU_SaleStatisticImport
{
    public partial class ActivityDetails : System.Web.UI.UserControl
    {
        public string ActivityCode
        {
            get
            {
                if (ViewState["ActivityCode"] == null)
                {
                    return "";
                }
                return (string)ViewState["ActivityCode"];
            }
            set
            {
 
                ViewState["ActivityCode"] = value;
 
            }
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            lbltest.Text += "<br>Activity code: " + ActivityCode;
        }
    }
}
Svetlina Anati
Telerik team
 answered on 03 Feb 2011
6 answers
596 views

I diamically added 2 columns to the grid when page load,  one GridHTMLEditorColumn is editable and another one is enabled=false, how I get both Radedit value (edited value and enabled=false's cell value) on InsertCommand and UpdateCommand?

 

 

On form load:

 

 

 

 

GridHTMLEditorColumn boundColumn = new GridHTMLEditorColumn();

 

 

 

// GridBoundColumn boundColumn = new GridBoundColumn(); 

 

 this.rgLanguages.MasterTableView.Columns.Add(boundColumn);

 

 

 

// this.rgLanguages.MasterTableView.Columns.Add(cBox.Text);

 

 

 

 

 

  

boundColumn.DataField = cBox.Text;

boundColumn.HeaderText = cBox.Text;

boundColumn.UniqueName = cBox.Value;

rgLanguages_InsertCommand;:

I tried (editedItem["English"].Controls[0] as RadEditor).Text to get value, it only works for NONE dinamically creaded value, but not work for dinamically created column.

How I get both editeable value and enbaled =false's Radedit value here?Thank,
Jessie

 

 

 

 

 

 

 

 

 

:

 

 

 

 

 

 

GP
Top achievements
Rank 1
 answered on 03 Feb 2011
1 answer
118 views
Hi.

I'm using a DatePicker to show data about a specific date, and there are also dates in which no data is related. Hence, I'm populating the picker with special days using the OnLoad event, enabling and disabling the dates between the MinDate and MaxDate, as it's being needed.

This is how I've done so far, populating from the picker's MinDate to the MaxDate, which works, but I'd like to populate by requesting dates everytime I navigate, within the picker's CalendarView, so everytime a request occurs, I only process no more than 40 Special Days, not every date of several months and so on:

protected void DatePicker_Load(object sender, EventArgs e)
{
            RadDatePicker picker = sender as RadDatePicker;
 
            DateTime[] dates = controller.GetCustomerBaseDates();
 
            picker.MinDate = dates.Min();
            picker.MaxDate = dates.Max();
 
            for (DateTime d1 = picker.MinDate; d1 <= picker.MaxDate; d1 = d1.AddDays(1))
            {
                RadCalendarDay day;
 
                bool exists = dates.Contains(d1);
 
                day = new RadCalendarDay { Date = d1, IsSelectable = exists, IsDisabled = !exists };
                day.ItemStyle.CssClass = exists ? "rcDataExists" : "rcDisabled";
 
                picker.Calendar.SpecialDays.Add(day);
            }
}


How could I add the special days every time navigation occurs?  I want to enable and disable these dates on navigation within the view, because a lot of dates would be involved in the process.

Regards.
Iana Tsolova
Telerik team
 answered on 03 Feb 2011
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?