Click here to Skip to main content
13,403,621 members (52,588 online)
Rate this:
Please Sign up or sign in to vote.

I am koti, i am faceing the problem when "asign the table to view state".the table contains the dynamic created dropdownlist with different "ids".
i asign the table to view state crror comes as follows
<asp:tabel ID="table1" runat="server">

if (int.TryParse(TextBox1.Text.Trim(), out numOfColumns) && int.TryParse(TextBox2.Text.Trim(), out numOfRows))
            //Generate the Table based from the inputs
            GenerateTable(numOfColumns, numOfRows, "eng"); 


private void GenerateTable(int colsCount, int rowsCount, string cat)
      //Table t = (Table)table1;
      for (int i = 0; i < rowsCount; i++)
         TableRow row = new TableRow();
         for (int j = 0; j < colsCount; j++)
            TableCell cell = new TableCell();
            //TextBox tb = new TextBox();
            DropDownList dl = new DropDownList();
            FileUpload ful = new FileUpload();
            // Set a unique ID for each TextBox added
            //tb.ID = "tb_" + i + "Col_" + j;
            dl.ID = cat + "dl_" + i + "Col_" + j;
            ful.ID = cat + "ful_" + i + "Col_" + j;
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter("select PaperName from [7Seas_News_displayT]", con);
            da.Fill(ds, "[7Seas_News_displayT]");
            cmd.CommandText = "select PaperName from [7Seas_News_displayT]";
            DataTable dt = new DataTable();
            dl.DataSource = dt;
            dl.DataTextField = "PaperName";
            //dl.DataValueField = "Sno";
            // Add the control to the TableCell
            // Add the TableCell to the TableRow
           // Add the TableRow to the Table
      //Creat the Table and Add it to the Page

Type 'System.Web.UI.WebControls.Panel' in Assembly 'System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable

if any one knows how to solve the this problem , please share the information for me.
Thanks In Advance.

/EDIT Inline code Format
Posted 22-Dec-12 0:20am
Updated 22-Dec-12 4:35am
Sandeep Mewara 22-Dec-12 5:31am
Not clear. Elaborate. Further, share the lines of code around which you get this. BTW, make sure that the .NET framework set across project and deployment are same.
db7uk 22-Dec-12 19:43pm
I would avoid using viewstate for data tables. Use session instead. Also agree with Sandeep. Question is not too clear.
thursunamy 24-Dec-12 15:31pm
If that table is datatable it is not serializable you can use Dataset. But I agree with db7uk. It is not a good solution to store a table in viewstate. It reduces the performance Session is better.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.1802120.2 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100