Grid - DockViewState Conflict

2 posts, 0 answers
  1. Abdullah Önden
    Abdullah Önden avatar
    20 posts
    Member since:
    Aug 2009

    Posted 21 Jan 2010 Link to this post


    I'm using a couple of grids in my docks. When I try to enable Dock's EnableViewState function, I figured out I can't reach my grid's item.DataItem values anymore. What's the reason? Any help?

    Here's my delete function:
        protected void btnDelete_Click(object sender, EventArgs e) 
            foreach (GridItem item in this.grdList.SelectedItems) 
                ShoppingCartItem cart = (ShoppingCartItem)item.DataItem; 

    Here's my init:
            protected override void OnInit(System.EventArgs e) 
                //find dock layouts
                DockLayout dockLayout = (DockLayout)FindControl("dockLayout"); 
                dockLayout.EnableViewState = false
                dockLayout.StoreLayoutInViewState = false
                //this.EnableViewState = false

  2. Pero
    Pero avatar
    1156 posts

    Posted 26 Jan 2010 Link to this post

    Hi Abdullah,

    I tried to reproduce the problem locally by creating a sample project, but with no success. The item.DataItem always returns null regardless of whether the ViewState is enabled or not. Here is the full source code of the project:

    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head id="Head1" runat="server">
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
                <telerik:RadDockZone ID="RadDockZone1" runat="server" MinHeight="300px" Width="300px">
                    <telerik:RadDock ID="RadDock1" runat="server" Width="300px" Title="RadDock-Title">
                            <telerik:RadGrid ID="GridView1" runat="server" OnNeedDataSource="OnNeedDataSource"
                                        <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
                                        <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                                <ClientSettings EnableRowHoverStyle="true">
                                    <Selecting AllowRowSelect="True" />
        <asp:Button ID="Button1" runat="server" Text="Delete" OnClick="btnDelete_Click" />
        <asp:Label ID="Label1" runat="server"></asp:Label>

    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;
    public partial class Default2 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        protected override void OnInit(System.EventArgs e)
            //find dock layouts                   
            //RadDockLayout dockLayout = (RadDockLayout)FindControl("RadDockLayout1");
            //dockLayout.EnableViewState = false;
            //dockLayout.StoreLayoutInViewState = false;
            //this.EnableViewState = false;        
        protected void btnDelete_Click(object sender, EventArgs e)
            foreach (GridItem item in this.GridView1.SelectedItems)
                Label1.Text = item.DataItem.ToString();
        protected void OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
            GridView1.DataSource = new string[] { "0", "1", "2", "3", "4", "0", "1", "2", "3", "4", "0", "1", "2", "3", "4", "0", "1", "2", "3", "4", "0", "1", "2", "3", "4" };

    Could you please send us a fully working sample that demonstrates the issue? Once we have a better view over the problem we can provide an adequate solution.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft R3 2016 release webinar banner
Back to Top