Error Serializing Value 'System.Web.UI.WebCOntrols.TreeNode' of type 'System.Web.UI.WebCOntrols.TreeNode'

Hi,

I am  getting the error stated in the subject when i am storing a TreeNode in a ViewState and then using it as follows

if (ViewState["ProductCounty"]!=null)

{

TreeNode _productCountyNode = DataTree.FindNode(((TreeNode)ViewState["ProductCounty"]).ValuePath);

_productCountyNode.Expand();

}

what could be causing this error?

0
Hellraiser2030
11/7/2008 9:03:31 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

2 Replies
1814 Views

Similar Articles

[PageSpeed] 18

Hi,

I believe TreeNode isn't serializable in a way its required for objects which can be put to ViewState - as reference - (TreeNode implements IStateManager and is meant to work together with TreeView itself saving its view state).

Since you use ValuePath anyway to find the node, so why wouldn't you store it to ViewState in the first place, instead of the entire object?


Thanks,

Teemu Keiski
Finland, EU
0
joteke
11/8/2008 7:55:23 AM

Thanks for the answer. After i posted this I checked the Attributes of a TreeNode object it didn't have Serializable and it provide i couldn't store it in a ViewState and had to go the route you described.

0
Hellraiser2030
11/8/2008 4:24:40 PM
Reply:

Similar Artilces:

Error: Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField'
Hello, I am getting the following error during compiliation. Any suggestions to fix it. Thanks. Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField' protected void gvEvents_RowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvEvents.Rows[index]; string sID; ButtonField btn; if (selectedRow.RowType == DataControlRowType.DataRow) { sID = ((ButtonField)selectedRow.FindControl("ID")).DataTextFi...

Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox'
I am attempting to "Update" a field in a Datagrid, but no matter what I do (Using either Label or Text Boxes)  I keep getting the same error: Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox' The Error is highlighted below in the Sub... <==THE FIELD THAT CALLS THE ERROR  Any help would be greatly appreciated !!! Thanks !!   The code is as follows... <table border=0 height=210 bordercolor=olive ><tr valign=top><td> <asp:datagrid id="FacilityDataGrid"...

Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.
Hi,  I have a formview with a dropdownlist created dynamically. i want to determine whether the dropdownlist was clicked. the code is written in the FormView1_DataBound method. I get the following error in the line below that is in italics and underlined: Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.   Here is my code: ddl_iFullname = New DropDownList ddl_iFullname.ID = "ddl_iFullname" ddl_iFullname.DataSource = ObjectDataSource3 ddl_iFullname.DataTextField = "fullname" ddl_iFullname.DataValueField = "...

ASPNET2 HELP! CS0266: Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.FileUpload'.
Server Error in '/start-movieposters' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0266: Cannot implicitly convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.FileUpload'. An explicit conversion exists (are you missing a cast?) Source Error: ...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'
Hello, Goal: enter a number in two fields HoursPerUnit and PeoplePerUnit and the value for the third field, TotalHoursPerUnit will populate after the the number in the two fields have been caculated.  Using the code below I receive the error message above.  Please tell me what am I doing wrong? Do I need to cast the text as a literal?  Please help? Thank you in advance, <%@ Page Language="VB" MasterPageFile="Default.master" AutoEventWireup="false" CodeFile="frmHR.aspx.vb" Inherits="frmHR"...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'.
Hi, any idea why I'm getting the following error?Line 45: protected void CartGrid_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) Line 46: { Line 47: TextBox QuantityTextBox = (TextBox)CartGrid.Rows[e.RowIndex].Cells[2].Controls[0]; Line 48: int Quantity = Convert.ToInt32(QuantityTextBox.Text); Line 49: Are you sure that the control at CartGrid.Rows[e.RowIndex].Cells[2].Controls[0] isn't a LiteralControl?  How are you creating code this in your code?Brent JenkinsASP.NET, C#, Web Developerwww.valewebdesign.co.uk  ...

Error 1 The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\asse
Once I build project. I encounter this error. Does someone experience this error?Error    1    The type 'System.Web.UI.WebControls.LinqDataSource' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35\System.Web.Extensions.dll'    D:\Source Code\Linq_Lesson5\Default.aspx    1    1    D:\Source Code\Linq_Lesson5\  It appears tha...

The base class includes the field 'MyList', but its type (System.Web.UI.WebControls.DataList) is not compatible with the type of control (System.Web.UI.WebControls.DataGrid).
Hi guys,I am very new to asp.net and have been playing with the commerce starter kit at - http://asp.net/CommerceStarterKit/ one of the first pages that lists the catalogue items "ProductsList.aspx" uses a datalist, I need to use a datagrid as I need to use pagination as my catalogue is so huge, I have changed the necessary attributes in the ProductsList.aspx page to datagrid and also in the codebehind file ProductsList.aspx.vb, when I run the page I get the Error message below. Description: An error occurred during the parsing of a resource required to ser...

The base class includes the field 'MyList', but its type (System.Web.UI.WebControls.DataList) is not compatible with the type of control (System.Web.UI.WebControls.DataGrid).
Hi guys,I am very new to asp.net and have been playing with the commerce starter kit at - http://asp.net/CommerceStarterKit/ one of the first pages that lists the catalogue items "ProductsList.aspx" uses a datalist, I need to use a datagrid as I need to use pagination as my catalogue is so huge, I have changed the necessary attributes in the ProductsList.aspx page to datagrid and also in the codebehind file ProductsList.aspx.vb, when I run the page I get the Error message below. Description: An error occurred during the parsing of a resource required to ser...

Value of type 'System.Web.UI.Control' cannot be converted to 'System.Web.SiteMap'.
 Hello,         I receive this error "System.Web.UI.Control' cannot be converted to 'System.Web.SiteMap" when I try to find the Sitemap control.  ...            <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />            <asp:ListView ID="ListView1" runat="server">            <LayoutTemplate>    ...

Error showing up: Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'System.IConvertible'.
Hi, I am trying to pass date values from two textboxes in a stored procedure from ASP.net page. However, it seems it is not passing the date properly. I am getting the following error at the following line: cmd_r.Parameters("@initial_est_date").Value = Convert.ToDateTime(Textbox1)  and the error is as stated in the title. I would appreciate any help to resolve this. Thanks  CODE:<%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %><%@ Import Namespace="System.Data.Common" %> <%@ I...

BC30311: Value of type 'Control' cannot be converted to 'System.Web.UI.WebControls.CheckBox'
 Hi, can somebody help me on this problem. It works at first, but all of a sudden, it fails, and I can't find out why.    1 Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) 2 3 If Not CheckRequiredField() Then 4 MessageBox("Please complete the input data!") 5 Exit Sub 6 End If 7 8 Dim nRow As Integer 9 Dim Ctrl As Control 10 Dim chkDelete As Object 11 Dim LookupID, Name, Desc, Type As String 12 13 nRow = 0 14 1...

Having an error: BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label'.
Error Message: Compiler Error Message: BC30311: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls.Label'. Line 13: myGetRandom.RetrieveDetails(lblQuestion.text, lblAnswers.text, lblViewCount.text, lblLastUpdated.text) Sub Page_Load Dim myGetRandom as new GetRandom myGetRandom.RetrieveDetails(lblQuestion.text, lblAnswers.text, lblViewCount.text, lblLastUpdated.text) End Sub Code behind Sub RetrieveDetails(lblQuestion as label, _ lblAnswers as label, _ lblViewCount as label, _ lblLastUpdated as...

Error 60 Operator '&' is not defined for types 'System.Web.UI.WebControls.TextBox' and 'String'.
The comment control is a textbox:<td align="right" style="width: 228px"><asp:TextBox ID="comment" runat="server" TextMode="multiLine" Rows="10" Columns="50" onkeyup="return ismaxlength(this)" Width="260px" Height="100px" Font-Overline="false" /></td> and I'm being told by VS (underlined in blue ) that the for the comment field: Error 60 Operator '&' is not defined for types 'System.Web.UI.WebControls.TextBox' and 'String...

Web resources about - Error Serializing Value 'System.Web.UI.WebCOntrols.TreeNode' of type 'System.Web.UI.WebCOntrols.TreeNode' - asp.net.navigation-controls

Resources last updated: 12/8/2015 7:53:35 AM