Welcome Guest Search | Active Topics | Sign In | Register

EO Grid and cell level editing. Options
KB
Posted: Wednesday, February 22, 2012 6:27:19 PM
Rank: Newbie
Groups: Member

Joined: 2/22/2012
Posts: 4
Hi,

I downloaded your web controls for evaluation. Specifically I'm interested in the grid for 'Excel Style' editing. I feel dumb because I can't get the simplest functionality to work. I created an empty web site, put the grid and a post back button on the default form. Changed the FullRowMode property to false, added a read only 'key' text box column, an editable text box column, then bound some data from a table to it. The display works fine. I tried the paging, reordering columns, etc this all seems good. However, when I change the editable column in a row and click my button to cause a post back I get :



Server Error in '/TESTEO' Application.

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.]
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +377
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225
System.Web.UI.Page.LoadAllState() +312
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +747



I've done ASP.net for a while but confess to being no expert on viewstate so it may be just someting i have set wrong. I DON'T get the error if I hit the button causing post back without changing anything.

SO I went to plan B. I set EnableViewstate to false on the grid control and ran it that way. I don't get the error but the 'ChangedItems' count is 0 no matter how many items I change. Is this because of viewstate??? Below is the code as simple as I could make it. Any help would be appreciated as it sounds like it will be exactly what I'm looking for if I can get it working.


Code: HTML/ASPX

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>

<form id="form1" runat="server">
<div>

<eo:Grid ID="Grid1" runat="server" BorderColor="#828790" BorderWidth="1px"
ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205"
ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24"
FixedColumnCount="1" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma"
Font-Overline="False" Font-Size="8.75pt" Font-Strikeout="False"
Font-Underline="False" FullRowMode="False" GridLineColor="240, 240, 240"
GridLines="Both" Height="200px" ItemHeight="19" Width="380px">
<ItemStyles>
<eo:GridItemStyleSet>
<ItemStyle CssText="background-color: white" />
<ItemHoverStyle CssText="background-image: url(00050206); background-repeat: repeat-x" />
<SelectedStyle CssText="background-image: url(00050207); background-repeat: repeat-x" />
<CellStyle CssText="padding-left:8px;padding-top:2px;white-space:nowrap;" />
</eo:GridItemStyleSet>
</ItemStyles>
<ColumnHeaderStyle CssText="background-image:url('00050201');padding-left:8px;padding-top:4px;" />
<ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px;" />
<Columns>
<eo:TextBoxColumn DataField="Number" HeaderText="Number" Name=""
ReadOnly="True">
</eo:TextBoxColumn>
<eo:TextBoxColumn DataField="Description" HeaderText="Description">
</eo:TextBoxColumn>
</Columns>
<FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
</eo:Grid>

</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>

</html>

Code: Visual Basic.NET

Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Sub BindData()
Dim wrksqlstm As String = ""
wrksqlstm = "Select Number, Description from SKU"
Dim conn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("WebOrdersConnection").ToString)
Dim ds As New System.Data.DataSet
Dim da As New System.Data.SqlClient.SqlDataAdapter(wrksqlstm, conn)
da.Fill(ds, "Item")
Grid1.DataSource = ds.Tables(0)
Grid1.DataBind()
End Sub

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Response.Write(Grid1.ChangedItems.Count & " Rows Changed")
End Sub
End Class





eo_support
Posted: Wednesday, February 22, 2012 7:25:13 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Your code looks quite correct. So this might be a bug. If you can isolate the problem into a standalone test page and post the test page, we will be very happy to take a look. You will need to remove your DB related code and use hard coded data instead. Once we have the code, we will run it here. As soon as we can reproduce the problem, we should be able to tell you what's wrong.

Thanks!
KB
Posted: Thursday, February 23, 2012 11:03:10 AM
Rank: Newbie
Groups: Member

Joined: 2/22/2012
Posts: 4
OK, I disconnected the data from the grid by just commenting out the BindData sub. Now I can add rows and see addedrecords.count on post back. The viewstate statys so i can then change the added records and see changedrecords.count on post back. When I turn enableviewstate off, i can add rows but not change of course since the viewstate is gone, but I still can't see addedrecords.count on postback.

So i guess with the enableviewstate on the BindData sub is doing something to the grid view state. What I can't imagine as i looked at your demo form and it was doing basically the same thing to the grid, setting a data source and binding.

Code: Visual Basic.NET
'Your demo code to bind data
        Grid1.DataSource = db.ExecuteReader(sql)
        Grid1.DataBind()

'My code to bind data
        Grid1.DataSource = ds.Tables(0)
        Grid1.DataBind()


Speaking of the demo, it works but it does say when I open it it was done in an older version of VS. I am on VS2010.40219.1 SP1 .Net framework 4.0.30319 SP1.

Secondly, are the added and changedrecords collection supposed to be available at postback with enableviewstate off?

Below is the code with the databind gone and the enableviewstate off. where i am seeing no addedrecords.count on postback. But again, my main issue is how the veiwstate is getting screwed up by just binding data.

Code: HTML/ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>

    <form id="form1" runat="server">
    <div>
    
        <eo:Grid ID="Grid1" runat="server" BorderColor="#828790" BorderWidth="1px" 
            ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205" 
            ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24" 
            FixedColumnCount="1" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" 
            Font-Overline="False" Font-Size="8.75pt" Font-Strikeout="False" 
            Font-Underline="False" FullRowMode="False" GridLineColor="240, 240, 240" 
            GridLines="Both" Height="200px" ItemHeight="19" Width="380px" 
            AllowNewItem="True" EnableViewState="False">
            <ItemStyles>
                <eo:GridItemStyleSet>
                    <ItemStyle CssText="background-color: white" />
                    <ItemHoverStyle CssText="background-image: url(00050206); background-repeat: repeat-x" />
                    <SelectedStyle CssText="background-image: url(00050207); background-repeat: repeat-x" />
                    <CellStyle CssText="padding-left:8px;padding-top:2px;white-space:nowrap;" />
                </eo:GridItemStyleSet>
            </ItemStyles>
            <ColumnHeaderStyle CssText="background-image:url('00050201');padding-left:8px;padding-top:4px;" />
            <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px;" />
            <Columns>
                <eo:TextBoxColumn DataField="Number" HeaderText="Number" Name="" 
                    ReadOnly="True">
                </eo:TextBoxColumn>
                <eo:TextBoxColumn DataField="Description" HeaderText="Description">
                </eo:TextBoxColumn>
            </Columns>
            <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
        </eo:Grid>
    
    </div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>

</html>


Code: Visual Basic.NET
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Response.Write(Grid1.AddedItems.Count & " Rows Added")
    End Sub
End Class
eo_support
Posted: Thursday, February 23, 2012 11:08:45 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You need to provide a test page that shows the problem with EnableViewState turned on. You must set EnableViewState to true in order for the Grid to function. So you can not simply turn it off.

Thanks
KB
Posted: Thursday, February 23, 2012 11:28:36 AM
Rank: Newbie
Groups: Member

Joined: 2/22/2012
Posts: 4
OK here you go, I run this, change a description and click the button and i get the viewstate error:

Code: HTML/ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>

    <form id="form1" runat="server">
    <div>
    
        <eo:Grid ID="Grid1" runat="server" BorderColor="#828790" BorderWidth="1px" 
            ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205" 
            ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24" 
            FixedColumnCount="1" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" 
            Font-Overline="False" Font-Size="8.75pt" Font-Strikeout="False" 
            Font-Underline="False" FullRowMode="False" GridLineColor="240, 240, 240" 
            GridLines="Both" Height="200px" ItemHeight="19" Width="380px" 
            AllowNewItem="True">
            <ItemStyles>
                <eo:GridItemStyleSet>
                    <ItemStyle CssText="background-color: white" />
                    <ItemHoverStyle CssText="background-image: url(00050206); background-repeat: repeat-x" />
                    <SelectedStyle CssText="background-image: url(00050207); background-repeat: repeat-x" />
                    <CellStyle CssText="padding-left:8px;padding-top:2px;white-space:nowrap;" />
                </eo:GridItemStyleSet>
            </ItemStyles>
            <ColumnHeaderStyle CssText="background-image:url('00050201');padding-left:8px;padding-top:4px;" />
            <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px;" />
            <Columns>
                <eo:TextBoxColumn DataField="Number" HeaderText="Number" Name="" 
                    ReadOnly="True">
                </eo:TextBoxColumn>
                <eo:TextBoxColumn DataField="Description" HeaderText="Description">
                </eo:TextBoxColumn>
            </Columns>
            <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
        </eo:Grid>
    
    </div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>

</html>


Code: Visual Basic.NET
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            BindData()
        End If
    End Sub

    Sub BindData()
        Dim ds As New System.Data.DataSet
        Dim dt As System.Data.DataTable
        Dim dr As System.Data.DataRow
        Dim Number As System.Data.DataColumn
        Dim Description As System.Data.DataColumn

        dt = New System.Data.DataTable()
        Number = New System.Data.DataColumn("Number", Type.GetType("System.String"))
        Description = New System.Data.DataColumn("Description", Type.GetType("System.String"))

        dt.Columns.Add(Number)
        dt.Columns.Add(Description)

        dr = dt.NewRow()
        dr("Number") = "Item 1"
        dr("Description") = "Description 1"
        dt.Rows.Add(dr)

        dr = dt.NewRow()
        dr("Number") = "Item 2"
        dr("Description") = "Description 2"
        dt.Rows.Add(dr)

        ds.Tables.Add(dt)

        Grid1.DataSource = ds.Tables(0)
        Grid1.DataBind()

    End Sub

    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Response.Write(Grid1.ChangedItems.Count & " Rows Changed")
    End Sub
End Class
eo_support
Posted: Thursday, February 23, 2012 3:06:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We tested your code and it worked fine here. You may want to check whether you have the latest version first.

Thanks!
KB
Posted: Thursday, February 23, 2012 4:07:57 PM
Rank: Newbie
Groups: Member

Joined: 2/22/2012
Posts: 4
My .dll shows version 9.0.37.2. Downloaded and installed it yesterday. strange.
eo_support
Posted: Thursday, February 23, 2012 4:32:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We do not know what can be the problem then. We are running the same version and it works fine here. You may want to try it in a blank new project or from our sample project, or from another machine. We cannot do anything about it unless we can reproduce it.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.