This is a migrated thread and some comments may be shown as answers.

Grid - DockViewState Conflict

1 Answer 47 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Abdullah Önden
Top achievements
Rank 1
Abdullah Önden asked on 21 Jan 2010, 05:59 PM
Hi

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; 
            SiteManager.Params.CurrentUserShoppingCart.Remove(cart); 
        } 
        RefreshLists(); 
    } 

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
            PrepareLayoutDocks(dockLayout); 
            //this.EnableViewState = false
            base.OnInit(e); 
        } 



1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 26 Jan 2010, 12:11 PM
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" "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 ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <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">
                    <ContentTemplate>
                        <telerik:RadGrid ID="GridView1" runat="server" OnNeedDataSource="OnNeedDataSource"
                            AllowMultiRowSelection="true">
                            <MasterTableView>
                                <Columns>
                                    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
                                    <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>
                            </MasterTableView>
                            <ClientSettings EnableRowHoverStyle="true">
                                <Selecting AllowRowSelect="True" />
                            </ClientSettings>
                        </telerik:RadGrid>
                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
    </div>
    <asp:Button ID="Button1" runat="server" Text="Delete" OnClick="btnDelete_Click" />
    <asp:Label ID="Label1" runat="server"></asp:Label>
    </form>
</body>
</html>

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;
        //PrepareLayoutDocks(dockLayout);
        //this.EnableViewState = false;        
        base.OnInit(e);
    }
 
    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.


Regards,
Pero
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.
Tags
Dock
Asked by
Abdullah Önden
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or