Click here to Skip to main content
16,022,362 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i have a dropdown ,textbox and a button gridview footer what m doing is adding dropdownselected value and textbox text on button click when i add two times it works but when i click on button 3rd time i get this exception ...i have also tried enable viewstate=false but then only one item is added since viewstate is enabled i m also creating dynamic controls on gridviewrowdatabound here's my code i dont where have i done mistake

foreach (TableCell tb in e.Row.Cells)
                {
                    int cellIndex = e.Row.Cells.GetCellIndex(tb);
                    if (cellIndex != 0)
                    {
                        TextBox Txt = new TextBox();
                        if (tb.Text != " ")
                            Txt.Text = tb.Text;
                        Txt.ID = "txt_" + i;
                        Txt.Width = 30;
                        i++;
                        tb.ID = "tb_" + i;
                        Txt.EnableViewState = false;
                        tb.EnableViewState = false;
                        tb.Controls.Clear();
                        tb.Controls.Add(Txt);
                    }
                }
Posted
Updated 1-May-11 23:46pm
v2
Comments
Sandeep Mewara 2-May-11 5:26am    
Wrap your code part in PRE tag. It will make your question readable.

If I get an exception while programming, the first thing that I do is search Google/Bing for the exception. 99.99% of the times, I get a solution. I did the same for your question and this was the very first result - Failed to load viewstate ? Typical problem, with an obvious solution[^]
More here - Google search - Failed to Load ViewState[^].

I hope that idea of Googling will save you (and us) a lot of time in the future! :thumbsup:
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900