Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
95 views
Hello,

I have a shared user control.  This UC is in one page and everything works fine.  In the second page, the RadTextBox client-API get_value() method reports "", when it has a legitimate value.  There is very little javascript on that page, and it's not targeting textboxes; it's in a page with 6 tabs.  The controls work fine; I have RadCombo's and the drop downs work as you would expect.  But no text, no selected value, nothing is being reported (I have a script to check if the page is an empty form).  How do I even debug this to figure out what is going on, and why the value isn't being reported?

Thanks.
Brian Mains
Top achievements
Rank 1
 answered on 02 Dec 2010
1 answer
96 views
Hello,
in my web application I have a problem using GridSettingsPersister. In the applcation I have different RadGrid and I want let the user modify them (move columns, change column order/visibility/size). So i followed the instruction at http://demos.telerik.com/aspnet-ajax/grid/examples/programming/savinggridsettingsonperuserbasis/defaultcs.aspx.

I want the user to access a single page where he can choose which RadGrid to modify. After he choses the RadGrid, the application loads the chosen view grid into a panel and let the user modify it. After that we can save the configuration string in database.

I've used the GridSettingsPersister class of the example.

My problem is this:
- I choose the radgrid and load the radgrid to modify into the panel
- I modify some column visibility  (show only 3 columns for example)
- I correctly save the settings into db
- I load the configuration from database string (here all works fine)
- I add visibility to another column and retry to save
- Now I load the settings from the database string instead of havinf 4 columns I see all columns of grid (it seems a wrong configuration string has been saved into database)

I use the following code to:
-load configuration
public static void LoadGridConfiguration(RadGrid pRdg, long pIdGruppoUtente, bool loadDefaultString = false)
   {
       GridSettingsPersister gsp = new GridSettingsPersister(pRdg);
 
       using (DMWEntities context = new DMWEntities())
       {
           long idControlloAspx = (from ctrl in context.ControlliAspx
                                   where (ctrl.NomeControllo == pRdg.ID)
                                   select ctrl.IdControlloAspx).SingleOrDefault();
 
           if (idControlloAspx == 0)
           {
               throw new Exception("Grid Control not defined in database [ControlliAspx]");
           }
 
           var stringaConfigurazioneGruppoUtente = (from pg in context.ProprietaGriglie
                                                    where (pg.IdControlloAspx == idControlloAspx) && (pg.IdGruppoUtente == pIdGruppoUtente)
                                                    select new { pg.StringaConfigurazione, pg.StringaConfigurazioneDefault }).FirstOrDefault();
 
           if (loadDefaultString)
           {
               gsp.LoadSettings(stringaConfigurazioneGruppoUtente.StringaConfigurazioneDefault);  
           }
           else
           {
               gsp.LoadSettings(stringaConfigurazioneGruppoUtente.StringaConfigurazione);
           }
       }
   }

-save configuration
protected void btnPersistConfiguration_Clicked(object sender, EventArgs e)
    {
        MachinaWeb.ServerControls.RadPageView paginaConComboIdGruppoUtente = (MachinaWeb.ServerControls.RadPageView)((System.Web.UI.Control)MachinaWeb.ServerControls.Utility.FindControlType((Control)sender, typeof(MachinaWeb.ServerControls.RadPageView)));
        MachinaWeb.ServerControls.RadGrid gridUC = (MachinaWeb.ServerControls.RadGrid)((System.Web.UI.Control)MachinaWeb.ServerControls.Utility.FindControlType((Control)sender, typeof(MachinaWeb.ServerControls.RadGrid)));
 
        long selectedGU = long.Parse( ((RadComboBox)paginaConComboIdGruppoUtente.FindControl("blccmbGruppoUtente")).SelectedValue );
 
        //MessageBox.ShowTelerik(Page, this, "Configurazione salvata (Id Gruppo " + blccmbGruppoUtente.SelectedValue + ")");
 
        string gridName = gridUC.ID;
 
        using (DMWEntities context = new DMWEntities())
        {
            long idControlloAspx = (from ctrl in context.ControlliAspx
                                    where (ctrl.NomeControllo == gridName)
                                    select ctrl.IdControlloAspx).SingleOrDefault();
 
            if (idControlloAspx == 0)
            {
                throw new Exception("Grid Control not defined in database [ControlliAspx]");
            }
 
 
            var propGriglia = (from pg in context.ProprietaGriglie
                               where (pg.IdControlloAspx == idControlloAspx) && (pg.IdGruppoUtente == selectedGU)
                               select pg).FirstOrDefault();
 
 
            GridSettingsPersister gsp = new GridSettingsPersister(gridUC);
            string stringaConfigurazioneVista = gsp.SaveSettings();
 
            if (propGriglia == null)
            {
                //Creates row in database [Proprieta griglie]
                ProprietaGriglie pgNew = new ProprietaGriglie() { IdGruppoUtente = selectedGU, NomeGriglia = gridName, StringaConfigurazione = stringaConfigurazioneVista, IdControlloAspx = idControlloAspx, DataCreazione = DateTime.Now, DataAggiornamento = DateTime.Now, IdUtente = ((SessionInformation)Session["sessionData"]).IdUtente };
                context.ProprietaGriglie.AddObject(pgNew);
                context.SaveChanges();
            }
            else
            {
                //Updates row [Proprieta griglie]
                var pg = (from pgUpd in context.ProprietaGriglie
                          where (pgUpd.IdControlloAspx == idControlloAspx) && (pgUpd.IdGruppoUtente == selectedGU)
                          select pgUpd).Single();
 
                pg.StringaConfigurazione = stringaConfigurazioneVista;
                context.SaveChanges();
            }
 
        }
    }

-this is the code behind of my page
public partial class Configurazione_VisteTabellari : System.Web.UI.Page
{
    private RadGrid rdg = new RadGrid();
 
    protected void Page_Init(object sender, EventArgs e)
    {
        hfdIdCultura.Value = ((SessionInformation)Session["sessionData"]).IdCultura.ToString();
    }
 
    protected override void InitializeCulture()
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(((SessionInformation)Session["sessionData"]).Cultura);
        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(((SessionInformation)Session["sessionData"]).Cultura);
        base.InitializeCulture();
    }
 
 
    protected void Page_Load(object sender, EventArgs e)
    {
        //string resource_ModificareLayoutTabella = (string)GetGlobalResourceObject("Resource", "MessaggioModificaLayoutTabella");
 
        using (DMWEntities context = new DMWEntities())
        {
            if (!String.IsNullOrEmpty(hdfIdMascheraSelezionata.Value))
            {
                long idMascheraSelezionata = long.Parse(hdfIdMascheraSelezionata.Value);
 
                string urlVisioneTabellare = (from masc in context.Maschere
                                              where masc.IdMaschera == idMascheraSelezionata
                                              select masc.UrlControlloVistaTabellare).Single<string>();
 
 
                try
                {
                    RadGridStabilimenti uc = ((RadGridStabilimenti)LoadControl(urlVisioneTabellare));
                    uc.Type = CommonParameters.RadGridType.Configurazione;
                    pnlVistaTabellare.Controls.Clear();
                    pnlVistaTabellare.Controls.Add(uc);
                }
                catch (Exception)
                { }
 
                //Loads stringa configurazione di default per la grid
                //RadGrid gridUC = ((IUserControlGrid)pnlVistaTabellare.Controls[0]).GetGrid();
 
                //if (!Page.IsPostBack)
                //{
                //    try
                //    {
                //        Utility.LoadGridConfiguration(gridUC, ((SessionInformation)Session["sessionData"]).IdGruppoUtente, true);
                //    }
                //    catch (ArgumentNullException)
                //    {
                //    }
                //}
 
                string selectedGU = (((SessionInformation)Session["sessionData"]).IdGruppoUtente).ToString();
                blccmbGruppoUtente.SelectedValue = selectedGU;
                blccmbGruppoUtente.DataBind();
                //gridUC.DataBind();
            }
        }
    }
 
    protected void rtsPagina_TabClick(object sender, RadTabStripEventArgs e)
    {
        rts_Pagina.SelectedIndex = e.Tab.Index;
        rmp_Pagina.SelectedIndex = e.Tab.Index;
    }
 
    protected void RadGridVisioniTabellari_ItemCreated(object sender, GridItemEventArgs e)
    {
        ////Sets filter's textbox width
        //if (e.Item is GridFilteringItem)
        //{
        //    //30px di differenza rispetto alla larghezza della colonna
        //    GridFilteringItem gridFilteringItem = (GridFilteringItem)e.Item;
        //    ((TextBox)(gridFilteringItem["NomeMaschera"]).Controls[0]).Width = Unit.Pixel((int)(900 - CommonParameters.GridFilterWidthDistances));
        //}
    }
    protected void btnLoadConfiguration_Click(object sender, EventArgs e)
    {
        RadGrid gridUC = ((IUserControlGrid)pnlVistaTabellare.Controls[0]).GetGrid();
        string gridName = gridUC.ID;
        GridSettingsPersister gsp = new GridSettingsPersister(gridUC);
 
        Utility.LoadGridConfiguration(gridUC, long.Parse(blccmbGruppoUtente.SelectedValue));
    }
 
}



Veli
Telerik team
 answered on 02 Dec 2010
1 answer
100 views
My problem is that when i move from radgrid page1 to page 2 DataBound event is not calling,where i have written my necessary code.

        protected void gdTools_DataBound(object sender, EventArgs e)
        {
           
            clsVehicleToolMaping vhcleToolMapping = new clsVehicleToolMaping();
            //get all tools from inventory
            DataSet ds = vhcleToolMapping.get_ToolsforMapping(int.Parse(cmbbxOffice.SelectedItem.Value));
           
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                //get all tools from ToolMapping
                DataSet ds2 = vhcleToolMapping.get_DetailsfromToolsMapping(int.Parse(ds.Tables[0].Rows[i]["SPECPARTNOID"].ToString()));
                for (int j = 0; j < ds2.Tables[0].Rows.Count; j++)
                {
                    int vrno = int.Parse(cmbbxVrnno.SelectedItem.Value);
                    if (vrno == int.Parse(ds2.Tables[0].Rows[j]["INTERNALVRNNO"].ToString()))
                    {
                        for (int k = 0; k < gdTools.Items.Count; k++)
                        {
                            if ((gdTools.Items[k][gdTools.Columns[0]].Text) == (ds.Tables[0].Rows[i]["SPECPARTNOID"].ToString()))
                            {
                                CheckBox cb = (CheckBox)gdTools.Items[k][gdTools.Columns[2]].FindControl("chkbxStatus");

                                cb.Enabled = false;
                                cb.Checked = true;
                            }
                        }
                    }
                }
            }
      }
private void fill_grid()
        {

            clsVehicleToolMaping vhcleToolMapping = new clsVehicleToolMaping();
            ds = vhcleToolMapping.get_ToolsforMapping(int.Parse(cmbbxOffice.SelectedItem.Value));
            if (ds.Tables[0].Rows.Count > 0)
            {
                gdTools.DataSource = ds;
               
            }
           

            
        }

        
        protected void gdTools_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {

            if (cmbbxVrnno.SelectedIndex > 0)
            {
                fill_grid();
                this.gdTools.DataSource = this.ds;

            }
        }
--------------------------------------
This is my Radgrid designer
----------------------------------------
<telerik:RadGrid ID="gdTools" runat="server" AllowMultiRowSelection="true" Skin="Vista"
                AllowPaging="true" PageSize="1" AutoGenerateColumns="false"
                onneeddatasource="gdTools_NeedDataSource"
                    onitemdatabound="gdTools_ItemDataBound" ondatabound="gdTools_DataBound">
                    <MasterTableView >
                        <Columns>
                            <telerik:GridBoundColumn UniqueName="SPECPARTNOID" SortExpression="SPECPARTNOID"
                              HeaderText="SPECPARTNOID" DataField="SPECPARTNOID" ReadOnly="true" >
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn UniqueName="COMMODITY" SortExpression="COMMODITY"
                              HeaderText="COMMODITY" DataField="COMMODITY" ReadOnly="true" >
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn HeaderText="Status" UniqueName="MyTemplateColumn">
                                <ItemTemplate>
                                    <asp:CheckBox id="chkbxStatus" runat="server" >
                                    </asp:CheckBox>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>

           i have tried  the databound event code in item_databound event but the problem is that

for (int k = 0; k < gdTools.Items.Count; k++)

when the control goes to the above code count is always shown as zero.so events are not happening that are inside the for loop

        
Tsvetoslav
Telerik team
 answered on 02 Dec 2010
1 answer
65 views
Hai


I need to bind lacs of record to a radgrid. Instead of binding all records in need data source at i am binding only 10 records to the first page. When the user clicks on pagination link, i fetch the next set of rows from db and bind it to the radgrid. I pass the row start and ending position as argument to the database. It will work fine if the record count is less.When i increase the data the performance is slow. How can i increase the speed.

In SP i create a temp table to select the top rows And from the temptable i get the last 10 rows that i required for the particular page. 

Is there any way to select the row between the particular row number?


Thanks

Tsvetoslav
Telerik team
 answered on 02 Dec 2010
0 answers
78 views
RESOLVED: See notes blow.

Dynamically adding a RadEditor to the page and then calling set_mode() in the OnClientLoad event causes RadEditor to render abnormally.

I've attached a screenshot of this behavior. Here is the code to reproduce the issue:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
 
<%@ Register Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server" language="vbscript">
    Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click
        Dim div As New HtmlGenericControl("div")
        div.Style("height") = "300px"
        div.Style("border") = "1px solid #f00"
 
        Dim edt As New RadEditor()
        edt.Height = Unit.Pixel(300)
        edt.OnClientLoad = "function(editor,args){ editor.set_mode(1); }"
        div.Controls.Add(edt)
        pnl.Controls.Add(div)
    End Sub
</script>
 
<!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">
    <asp:ScriptManager runat="server" />
    <asp:Panel runat="server" ID="pnl">
        <asp:Button runat="server" ID="btn" Text="Load Controls" />
    </asp:Panel>
    <telerik:RadAjaxManager runat="server" DefaultLoadingPanelID="loading">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="pnl">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnl" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="loading">
        Loading...
    </telerik:RadAjaxLoadingPanel>
    </form>
</body>
</html>

Steps:
1. Click "Load Controls" button

Expected result:
RadEditor added to page with 300px height

Actual result:
RadEditor added to page with very large height

Notes:
Issue only occurs the first time "Load Controls" button is pressed. Subsequently pressing "Load Controls" will produce the expected results.

Browser: Firefox 3.6.12
Telerik version 2009.3.1314.35

------------------------------------------------------------------

Solution

I was able to resolve this issue by adding a slight delay...

setTimeout(function() { editor.set_mode(1); }, 100);
Kevin
Top achievements
Rank 1
 asked on 02 Dec 2010
1 answer
158 views
Hi together,

I have a little problem, i created a Grid with a SQL Data Source. In my Grid I display two Columns, the first is "ClassName from Table tblClass" and the second is "City" from tblCity. The selects are ok. Now if i update a row with this line

UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID"

the Name will update with the text that i put in the textbox. But i don't know how i can tell to FK_CityID = "selected dropdown value"

In my Dropdown i have the Property ListValueField="PK_City_ID", so that means i have only to replace the fix ID that i have now with the selected dropdown value. But I have no idea how I can do it.

Can someone help me please? thanks a lot

Here is my Code

<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True" Skin="Windows7" 
            AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True"
            AutoGenerateColumns="False" DataSourceID="SessionDataSource1" OnItemUpdated="RadGrid1_ItemUpdated"
            OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound">
            <PagerStyle Mode="NextPrevAndNumeric" />
              
            <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="PK_ClassID"
                DataSourceID="SessionDataSource1" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                  
                  
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                      
<%--                    <telerik:GridBoundColumn DataField="PK_ClassID" HeaderText="ID" SortExpression="PK_ClassID"
                        UniqueName="PK_ClassID" ColumnEditorID="GridTextBoxColumnEditor1">
                    </telerik:GridBoundColumn>--%>
                      
                    <telerik:GridBoundColumn DataField="ClassName" HeaderText="Class Name" SortExpression="ClassName"
                        UniqueName="ClassName" ColumnEditorID="GridTextBoxColumnEditor2">
                    </telerik:GridBoundColumn>
                      
  
                    <telerik:GridDropDownColumn DataField="FK_CityID" DataSourceID="SqlDataSource1"
                        HeaderText="City" ListTextField="City" ListValueField="PK_CityID"
                        UniqueName="PK_CityID" ColumnEditorID="GridDropDownColumnEditor1">
                    </telerik:GridDropDownColumn>
  
  
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
                  
                  
                  
                <EditFormSettings ColumnNumber="2" CaptionDataField="FK_CityID" CaptionFormatString="Bearbeiten der Klasse {0}" InsertCaption="Neue Klasse">
                   <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record"
                        UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
  
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" />
        <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" />
        <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" />
        <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" />
       
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server"></telerik:RadWindowManager>
        <br />
  
        <asp:SqlDataSource ID="SessionDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [tblClass]"
            DeleteCommand="DELETE FROM [tblClass] WHERE [PK_ClassID] = @original_PK_ClassID" 
            InsertCommand="INSERT INTO tblClass(ClassName, FK_CityID) VALUES (@ClassName, @FK_CityID)"
            UpdateCommand="UPDATE [tblClass] SET [ClassName] = @ClassName, [FK_CityID] = 2 %> WHERE [PK_ClassID] = @original_PK_ClassID"
            OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
            <DeleteParameters>
                <asp:Parameter Name="original_PK_ClassID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ClassName" Type="String" />
                <asp:Parameter Name="FK_CityID" Type="Int32" />
                <asp:Parameter Name="original_PK_ClassID" Type="Int32" />
                <asp:Parameter Name="PK_CityID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
            </InsertParameters>
</asp:SqlDataSource>
  
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Server=.\SQLExpress ;Database=IntraIBZ;Trusted_Connection=True;"
            ProviderName="System.Data.SqlClient" SelectCommand="SELECT [PK_CityID], [City] FROM [tblCity]">
        </asp:SqlDataSource>
  
  
                <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
  
            <script type="text/javascript">
                function RowDblClick(sender, eventArgs) {
                    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                }
            </script>
  
        </telerik:RadCodeBlock>
Tsvetoslav
Telerik team
 answered on 02 Dec 2010
1 answer
65 views
Dear Forum,

I have a RadGrid with drag-and-drop grouping enabled and a default top level grouping set. I'm using the Q1 2010 build with VS2008 and ASP.net 3.5 C#.

I collapsed all to the top level grouping using the example from
http://www.telerik.com/help/aspnet-ajax/grdcollapseallitemsongrouping.html

What I would like to do is to collapse all groups except for the last group the client selects each time the client drags and drops a new group to the group by bar.

Does anyone have an example of this or can anyone point me in the right direction.

Thank you,
Celeste
Tsvetina
Telerik team
 answered on 02 Dec 2010
7 answers
219 views
Hi!

I've been fiddling a bit with the new TreeList control, and manage to add some template columns dynamically.
It seems it's ok to remove a few and add more, but when I remove a lot and add less, I get an exception saying


Invalid column type: "TreeListTemplateColumn".

[Exception: Invalid column type: "TreeListTemplateColumn".]
   Telerik.Web.UI.RadTreeList.CreateColumnByType(String columnType) +184
   Telerik.Web.UI.TreeListColumnsCollection.System.Web.UI.IStateManager.LoadViewState(Object state) +350
   Telerik.Web.UI.RadTreeList.LoadViewState(Object savedState) +97
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221
   System.Web.UI.Page.LoadAllState() +312
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661

This also happens when "a lot" of columns has been added and I try to collapse a section.

I guess it's pretty easy to reproduce if you just fiddle a bit with the following page / code.
Try for instance to expand "A", then click "Month", and try to collapse "A".
Or just click "Month" then "Quarter".

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeViewTimeline.aspx.cs"
    Inherits="Web20.TreeViewTimelineTelerik.TreeViewTimeline" EnableEventValidation="false" %>
  
<%@ 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">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:LinkButton ID="QtrButton" runat="server" Text="Quarter" OnClick="QtrButtonClicked" />
        <asp:LinkButton ID="MonthButton" runat="server" Text="Month" OnClick="MonthButtonClicked" />
      
        <div id="tbl-container">
            <telerik:RadTreeList runat="server" ID="treeList" Skin="Vista" AutoGenerateColumns="False"
                OnInit="treeListInit"
                DataKeyNames="ID" ParentDataKeyNames="Parent" OnItemCommand="treeListItemCommand"
                  
                >
                <Columns>
                    <telerik:TreeListTemplateColumn UniqueName="Name" HeaderText="Navn" >
                        <HeaderStyle />
                        <ItemStyle />
                        <ItemTemplate>
                            <asp:TextBox runat="server" ID="NameTextBox" Text='<%# Eval("Name") %>' />
                        </ItemTemplate>
                    </telerik:TreeListTemplateColumn>
                </Columns>
            </telerik:RadTreeList>
        </div>
    </div>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
  
namespace Web20.TreeViewTimelineTelerik
{
    public partial class TreeViewTimeline : System.Web.UI.Page
    {
        public string Mode
        {
            get { return ViewState["mode"] as string ?? "Quarter"; }
            set { ViewState["mode"] = value; }
        }
  
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();
            }
        }
  
        private void BindList() 
        {
            var list = new[]
                       {
                        new Item {ID = "A", Name = "A", Parent = "", Periods = new Dictionary<string, Period>
                              {{"Q1", new Period {Name = "Q1"}}, {"Feb", new Period {Name="1/10"}}}}
                        , new Item {ID = "B", Name = "B", Parent = ""}
                        , new Item {ID = "A.A", Name = "A.A", Parent = "A", Periods = new Dictionary<string, Period> 
                              {{"Q2", new Period { Name = "Qtr 2"}}, {"Q3", new Period {Name="Qty 3"}}, {"Mar", new Period{Name="2/10"}} }}
                       };
  
            treeList.DataSource = list;
            treeList.DataBind();
        }
  
        protected void treeListItemCommand(object sender, TreeListCommandEventArgs e)
        {
            if (e.CommandName == RadTreeList.ExpandCollapseCommandName)
            {
                ResetColumns();
            }
        }
  
        protected void treeListInit(object sender, EventArgs e)
        {
            InitColumns();
        }
  
        private void InitColumns()
        {
            switch(Mode)
            {
                case "Quarter":
                    string[] quarters = new[] {"Q1", "Q2", "Q3", "Q4"};
                    foreach(string quarter in quarters)
                        treeList.Columns.Add(new TreeListTemplateColumn{UniqueName = quarter, HeaderText = quarter, ItemTemplate = new PeriodTemplate(quarter)});
                    break;
                case "Month":
                    string[] months = new[] {"Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"};
                    foreach(string month in months)
                        treeList.Columns.Add(new TreeListTemplateColumn { UniqueName = month, HeaderText = month, ItemTemplate = new PeriodTemplate(month) });
                    break;
            }
        }
  
        private void ResetColumns() {
            RemoveDynamicColumns();
            InitColumns();
            BindList();
        }
  
        private void RemoveDynamicColumns()
        {
            for(int i = treeList.Columns.Count - 1; i>=1; i--)
                treeList.Columns.RemoveAt(i);
        }
  
        protected void QtrButtonClicked(object sender, EventArgs e)
        {
            Mode = "Quarter";
            ResetColumns();
        }
  
        protected void MonthButtonClicked(object sender, EventArgs e)
        {
            Mode = "Month";
            ResetColumns();
        }
    }
  
    public class PeriodTemplate : ITemplate
    {
        private readonly string quarter;
  
        public PeriodTemplate(string quarter)
        {
            this.quarter = quarter;
        }
  
        public void InstantiateIn(Control container)
        {
            Label label = new Label();
            label.EnableViewState = false;
            label.ID = quarter + "Label";
            Item dataItem = (Item)DataBinder.GetDataItem(container.BindingContainer);
            if (dataItem != null && dataItem.Periods != null)
            {
                if (dataItem.Periods.ContainsKey(quarter))
                    label.Text = dataItem.Periods[quarter].Name;
            }
            container.Controls.Add(label);
        }
    }
  
    public class Item
    {
        public string ID { get; set; }
        public string Parent { get; set; }
        public string Name { get; set; }
  
        public Dictionary<string, Period> Periods { get; set; }
    }
  
    public class Period
    {
        public string Name { get; set; }
    }
}

Hope you guys can help. :)

Lars-Erik

Lars-Erik
Top achievements
Rank 1
 answered on 02 Dec 2010
2 answers
91 views
Hi,

I upgrade my os WinXP to  Win7 64 bit but when debug my web application gives some javascript errors. For example; I have to put my web page below this code for RadComboBox;
Telerik.Web.UI.RadComboBox.prototype._removeDropDown = function() {
            var slide = this.get_dropDownElement().parentNode;
            slide.parentNode.removeChild(slide);
  
            if (this._disposeChildElements)
                $telerik.disposeElement(slide);
  
            if (!$telerik.isSafari)
                slide.outerHTML = null;
            this._dropDownElement = null;
        };

But this code block is not run on RadTabstrip. When I click another tab which has no RadCombobox that gives an error. Also I get javascript errors in  some pages redirecting. How to avoid this errors ?
YAVUZ
Top achievements
Rank 1
 answered on 02 Dec 2010
3 answers
133 views
Hi there,

I have an ASP.net wizard control, with a RadDatePicker on one of the steps. I have added a RequiredFieldValidator as per this documentation. 

Unfortunately, the validator isn't firing when I enter an invalid date, and I can move to the next step in the wizard. If I move to the next step, then return to the previous step and enter an invalid date, it then fires.

My code for the RadDatePicker and Validator is as below:
<telerik:RadDatePicker ID="rdpMAEDROut" Runat="server" Culture="en-US">
    <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False"
            ViewSelectorText="x" daynameformat="Short" showrowheaders="False"></Calendar>
    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
    <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy"
            emptymessage="dd/mm/yyyy" CssClass="RDPInvalid"></DateInput>
</telerik:RadDatePicker>
<asp:RequiredFieldValidator CssClass="RequiredFieldValidator"
        ID="rfvMAEDROut" runat="server"
     ControlToValidate="rdpMAEDROut"
        ErrorMessage="You must enter a valid value in this field." ></asp:RequiredFieldValidator>

Any ideas would be greatly appreciated :)

Maria Ilieva
Telerik team
 answered on 02 Dec 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?