Dynamic - Why Is ViewState Retained With An Dropdownlist But Not An Table
Jan 10, 2011
I have an asp.net web form, and on it I have two controls (well, more than these two but we'll focus on these) - the first is an asp:dropdownlist and the second is an asp:table.
Both of these controls are declared on the HTML side, and filled (child controls added) in the code-behind page.
My simple question (hopefully with a simple answer) is this:
Why does the viewstate persist for the dropdownlist, and NOT for the table?
I have to fill the table on every page load, but I can fill the dropdownlist once (using Not Page.IsPostBack), and it persists.
NOTE: I have read about the lifecycle of ASP.NET pages, and I have tried placing these same calls in the Init() and PreInit() page events with the same results.
View 3 Replies
Similar Messages:
Dec 3, 2010
We have a ASP.net form [.NET 3.5 on IIS 6] that loads controls dynamically. We are able to retain the values in the viewstate as long as the postback happens within 20 minutes. The database also gets updated properly. Everything works as expected.
However, If it takes more than 20 minutes for a user to fill out the form, the controls no longer retain their values during postbacks. The session values are intact, the user authentication is also intact. We tried several things
1) Added machine keys to web.config files - we have 2 web servers load balanced by Windows load balancer
2) We confirmed that the user are routed to the same server - because the sessions are sticky
3) Increased the session timeout to 60 minutes in IIS 6.0
4) Increased the Idle timeout for connection pool to 60 minutes
5) Changed Form authentication ticket timeout to 60 minutes
View 3 Replies
Aug 19, 2010
My asp.net application has a function that returns the HTML for the navigation menu for the user by getting it from a database
currently, I am storing the text in a session variable when the session begins and then use it to set the innerHtml of the navigation div on the on_load method.
The problem is that the pages now contain the
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPD..
with the value being 7000 characters long.
Is there any better way to do this or a different way to store and retrieve values without them being stored in the viewstate ?
The code is just this:
Session["menuHTML"] = (new NavMenu().GetMenuHTML());
navMenuDiv.InnerHtml = Session["menuHTML"].ToString();
The div is declared as
<div id="navMenuDiv" class="navMenuDiv" runat="server"></div>
View 2 Replies
Jul 23, 2010
I have created a button(x) dynamically,and in that button click event I am creating a textbox and one more button(y) with that button(x) is making as invisible. if I click button(y) I want to read the value of textbox(textbox.text) and make button(x) as visible.
View 12 Replies
Sep 14, 2010
I have a question about retrieving the values from dynamic created controls. I'am using an wizard witch collects it data based on the steps in the wizard. At a certain wizard step i generate dropdownlists and textboxes depending on some records from a database. At this point no problem, the controls are created perfect. When i press the next button on the wizard i read out the eventarg e.currentstepindex, iterate throug the gridview witch is displaying the controls and try to find the control with "findcontrol" function.
The controls are "nothing" and i cant access them. THe source code of the page lets me show that the controls are there and that they have the assigned ID's.I investigated on google what the problem could be. I has to do with the viewstate and i have to regenerate the controls on page_load.
View 5 Replies
Aug 10, 2010
I have a dynamic Table which contain 8 rows and 8 Colums
Table t = new Table();
TableRow rr = new TableRow();
TableCell cc = new TableCell();
and in the each Cell CC I add a dynamic Button(Or Linkbtn)
LinkButton LB1 = new LinkButton();
LB1.Text = "AM";
LB1.ID ="Link1";
cc.Controls.Add(LB1);
rr.Cells.Add(cc);
LB1.Click += new EventHandler(LB1_Click);
t.Rows.Add(rr);
i have a table with 8 rows , 8 colums and each cell contain a LinkButton (which diffrent in IDs) I want to add Lable in the same cell of this LinkBtn(LB1) which it clicked but I cann't What shoud I write here?
void LB1_Click(object sender, EventArgs e)
{
// throw new NotImplementedException();
}
View 1 Replies
Dec 11, 2013
I have a Webform with a TextBox (Static) and 3 TextBox (Dynamic - based on the following article: [URL].... )
How to use this scenario with a single GridView table?
Based on the User input, the GridView might have (1 + 3) columns; (1 + 6) columns; (1 + 9) columns; ...etc.
View 1 Replies
Jan 25, 2011
i am creating dynamic textbox onRowCreated event in gridview control, however when i try to findcontrol i get null
here is how i am dong...
protected void gvORg_RowCreated(object sender, GridViewRowEventArgs e)
{
if ((e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)) || (e.Row.RowState == DataControlRowState.Edit))
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
txBox txtReg = new TextBox();.....
View 2 Replies
Sep 14, 2010
[Code]....
How can I get those dynamic textbox values from dynamic tables? I am working with a masterpage.
View 4 Replies
Apr 22, 2010
I am creating a gridview dynamically in a custom control and adding it to a Panel. I set the EnableViewState = true. The problem is that on a page postback the GridView does not seem to retain its values. If I add a GridView through the UI then the viewstate is preserved. The problem seems to occur when it is put dynamically only.
View 2 Replies
Jan 27, 2011
Setup:
My page has a drop down whose values are dynamically populated. Based on which item is selected, a number of TextBoxes are dynamically created during runtime.The user then fills in information into the textboxes and clicks a submit button.
Problem:
After postback from the submit button, I need to again dynamically create the TextBoxes during Page_Init (BEFORE LoadViewState) so that after the ViewState loads, my Button_Click event can save/do whatever with the user input. PROBLEM is, I cannot recreate the textboxes based on the selection in the dropdown, because the dropdown hasn't been "selected" yet by LoadViewState.
SO, how can I read from the view state, create my textboxes, then let the viewstate populate the textboxes, and then the Button_Click will use the values??
The one thing I've attempted is to override the LoadViewState function so that I can read from the view state, create the boxes, and then load the viewstate again. This did NOT work, because the debugger never seemed to hit my overridden function.
[code]....
View 1 Replies
Oct 15, 2010
I have a set of dynamically-created (IE: by code) controls on my web page. Depending on which options the user decides to go (Edit/New), those controls are re-created with the appropriate information (IE: "with values" with Edit, "without values" with New).
Here's the situation:
- I create my controls in InitComplete when it comes to save the data (both on Edit/New) contained within the controls.
- I create my controls in PreLoad when it comes to load them initially (Both on Edit/New) in order to avoid the ViewState to kick in.
However, despite creating the controls after the ViewState has been applied (technically), the controls still somehow retain the pre-postback's information. IE: if I have options 2 and 4 selected and I choose "New", which should show the options without being selected, they remain selected no matter what. And this is true despite changing their values in the PreLoad state. From my understanding, creating a control in this fashion and at that point in the page lifecycle should override any values the ViewState might have had for those controls. I have also tried to disable the parent's control viewstate (Table.EnableViewState = false) again, to no avail.
I've tried using the Me.ViewState.clear() and Me.ClearChildViewSate prior to loading the initial values as well, but again all for naught. I do understand that any control created after the Init phase of the lifecycle has to play "catchup" with the current state, however I would expect that clearing the ViewState prior to creating the controls would fix this issue. It doesn't seem to.
View 1 Replies
Mar 29, 2010
I am trying to generate a dynamic table andd add rows to a ASP.Net table control on my UI. My problem is as I add a new row from MyTable, in to another table the table I am copying from, will loose one row. Here is the code:
Table
myTable = new
Table
();
[Code]....
am just reading one row in every loop and add that row in to another table object, why is 'myTable' loosing loosing one row in each loop?
View 7 Replies
Jan 13, 2010
My datasource is an ado data table that I have convert to a new data table so that each row in the original table is now a column with 1 row in my new table. I then bind the new datatable and create dynamic template fields with a text box where I bind the values. My problem is, when I try and retrieve the values changed by the user in the rowcommand event, the template columns no longer exists.
Does anyone know how i can retrieve these values? I've read over and over that you have to rebind the grid on each postback when you use dynamic templates, but I'm not sure how to do that and retrieve the values entered in the text boxes on the client side.
[Code]....
View 1 Replies
Mar 13, 2011
I'm quite new to this so excuse me if this is a stupid question.
I created an extended dropdownlist based on the instruction on the asp.net site.
[URL]
My control gets a list of items from LINQ to SQL.
here's my problem:
When the page I used the control on posts back, the list get's re-initialized and looses it's selection.
How do I overcome this problem and keep the selection upon postback?
[Code]....
View 3 Replies
Jul 27, 2010
I want to create a dynamic HTML table in C# and assign value.
View 4 Replies
Jun 4, 2010
I am dynamically creating a table that contains a textbox in each cell. The table is put in a placeholder control. Everything displays perfectly. The problem is when I go to retrieve the values entered in the cells. I have the code to generate the table in a separate method called CreateTable(). In order for my program to find a table in the placeholder when I go to save, I have to run CreateTable() in a postback event AND in the PageLoad event. If I call CreateTable() in only one of those places and I try to save, it says the placeholder is empty and, therefore, I cannot save the textbox contents. I've tried calling CreateTable() from InitLoad but that doesn't work because it needs to reference values from three static controls: 1 dropdown, 1 listbox, and 1 calendar control, which I don't believe have had their viewstate rendered yet.
View 1 Replies
Dec 3, 2010
The sites I mantain are using way too much ViewState and I'd like to reduce that so the size of the page is reduced. I've done a lot to remedy this but I have an issue relating to DropDown lists that use AutoPostbacks.I have a dropdown list with a lot of list items and a good part of the ViewState usage is to hold the list item data. If I disable ViewState and set the AutoPostBack property to true, the page will post back and in the page load I am trying to repopulate the dropdown list with cached data. However, it seems that the SelectedIndexChanged event doesn't fire when EnableViewState="false".Is it possible to make this work without enabling ViewState for the drodown list?
View 6 Replies
Apr 21, 2010
I have a DataTable with about 10,000 rows in it.
I would like to store this data once for aspx page. When the user selects different options in the page, data is further selected from the already stored DataTable.
I tried using the ViewState, but as soon as the data grows beyond 100 rows, performance degrades.
View 1 Replies
Sep 20, 2010
I have this code (just for example):
[Code]....
The Code-behind file looks like that:
[Code]....
So, when i use
[Code]....
SelectedIndexChanged event doesn't fire for the first item of the DropDownList. For any other item SelectedIndexChanged fires, but not for the first one.Could someone, please, explain what kind of magic is it?(I use Visual Studio 2008)
View 2 Replies
Mar 21, 2011
I need some help in the technical approach with the following scenario:-
1) A dropdownlist with some options. It has a postback action on the selectedIndexChange server side event handler. For example, lets say it contains language options such as english, french etc.
2) Repeater with a label and the textbox control. For example label is Emp Name and textbox is containing the Emp Designation. We have to save emp designation in the various languages.
3) Every time i pick something from the dropdown, i have to flip the textbox control and fill the form. Now i want to save the given data of the texbox in the viewstate. So that every time, the user changes the dropdown selection, he can see the repeater data corresponding to the dropdown selection.
4) I guess some kind of relationship between the dropdown option and the repeater data is needed. But how can we make this thing work.
Now which is the best technique to save the data on the server side? I have to keep it in the viewstate.
View 1 Replies
Feb 3, 2010
My problem is that I have an ASPX page which contains an ASP:Table. The rows for the table is added dynamically on Page_Load. One column in the table contains TextBoxes, BUT when I type something on a TextBox and cause a postback, I am unable to find the value just entered. And above that the table is not displayed after the postback.Can anyone help me please? I want to keep the table viewstate with the modified textbox values, so that when i post back to server, I can intercept these new values.
View 3 Replies
Jan 5, 2014
how to write a code to check the Transaction ID from SQL Table in view state gridview for each row data ?
For Example, select transID from Table.Current ID is 14481.
So now when i add in the view state grid view, it show the same trans number
Is it any method to write the + values in add row function in c# to increase the values ? as below is the c# code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[Code].....
View 1 Replies
Nov 19, 2010
I need to write a query to populate a gridview with minimum rates in ascending order for a month from three tables.For example i have three tables A,B,C as follows
TABLE A TABLE B
TABLE C
Id id id
Quote_no Quote_no Quote_ no
Name Rate1 Equip_name
Rate2 E_rate
Date R1_rate
R2_rate
Date
Now if the data is as follows
I need to get the Name from Table A ,minimum Rate1 and Rate2 values for a month in a dropdownlist from date field from Table B and the corresponding minimum rate(E_rate) for Equipment E1 and E2 only from Table C for the month in ascending order group by Name.
TABLE A
id
Quote_no
Name
1
101
XYZ
2
102
ABC
TABLE B
id
Quote_no
Rate1
Rate2
Date
1
101
105
200
12/11/2010
2
102
90
210
15/11/2010
TABLE C
id
Quote_no
Equip_name
E_rate
R1_rate
R2_Rate
Date
1
101
E1
60
0
0
12/11/2010
1
101
R1
0
110
0
12/11/2010
1
101
E2
80
0
0
12/11/2010
2
102
R2
0
0
300
15/11/2010
2
102
E2
100
0
0
15/11/2010
2
102
R1
0
60
0
15/11/2010
2
102
E1
230
0
0
15/11/2010
View 9 Replies
Feb 25, 2011
I have an ASCX control which is a special dropdownlist. I add that control dynamically to the page and fill it with data. This control has a postback that will change the contents of a second dynamically created standard dropdownlist.
When I change the selection on the first dropdown, the indexchanged fires and I get new data and attempt to place it in the second dropdownlist's items collection, by first clearing it then filling it with new data.
This works fine the first time a change the selection, but when I select a second time the following error is thrown:
The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.
I'm not adding or removing new controls in the fired event, only changing data. And again, it works the first time, but doesn't subsequent times.
If I disable stateview on the child control, then the control just doesn't get updated with data at all.
View 1 Replies