|
|
||||||
|
#1
|
|
|
|
|
1) I build a Html Table dynamically (Header Row, and then 2 rows with data
All 2 rows have 2 cells: cell(0) contains a delete button (ASP Button), cell(1) contains a HTML Text box 2) On Form Load and get some data from a dataset and then from it's contents build the page At this point the page is rendered and 2 rows are displayed. There is an Add button that a user can click to add another row to the table. This works fine and the row is added. Now if the user clicks the delete button in row 2 the form is posted back, I rebuild the page, and then in the click event for the delete button remove the row from the table and the dataset. All appears to be fine at this point. Now if the user clicks the add button again another row is added, but this time row 2's textbox has the wrong value. It appears to be related to the view state. I think the view state somehow is not getting cleared when the row is removed. Any help would be appreciated |
|
|
|
#2
|
|
|
|
|
Are you setting the value in the view state after deleting the row?
|
|
#3
|
|
|
|
|
I'm not sure what you mean. When the user clicks the delete row button:
1) postback to the page 2) rebuild the page(including the row that was deleted 3) delete the row from the table 4) update the dataset from which I deleted the table 5) Update the contents of the table As of now, all of the above is done during form load. Thanks for help! "Kurt Farrar" wrote: [..] |
|
#4
|
|
|
|
|
Shouldn't your code to delete the row from your dataset be in the
DeleteButton_Clicked event? My way of doing it would be (pseudo code): sub page_load if not(ispostback()) then createdataset 'create dataset from datasource savedataset 'put a copy of the dataset into the view state else loaddataset 'reload the dataset from the viewstate end if end sub sub addButton_Clicked addRow 'add row to dataset savedataset 'update the viewstate with the updated dataset end sub sub deleteButton_Clicked delRow 'remove the row from the dataset savedataset 'update the viewstate with the updated dataset end sub Hope this helps. |
|
|
| Similar Threads | |
| Dynamic controls, postbacks, and view state My application calls for a lookup table in which the user can add records. When the application is run, an html table will be created dynamically to show checkboxes (and... |
|
| Event handling of dynamic controls Hi, I'm creating 5 ImageButton controls in the panel control, and I have a unique ID specified for each one. When I click on any one of them, the Page_Load executes (Of... |
|
| event handling for dynamic controls I have a web page with a table that i generate rows for when a database query is run. Each row contains a button column and I would like to add a handler for the click event... |
|
| Dynamic Controls and View State Dear All, We all always have a problem dynamic controls and ViewState...Suppose we want to create dynamic Controls on Load of the page and Save its value in the ViewState and... |
|
| maintaining state for dynamic controls between PostBack() ??? Hi all. Relative newcomer to asp.net. I am constructing an asp.net/C# app that requires some metadata-based dynamic form creation (shows only those product details required... |
|
|
All times are GMT. The time now is 12:44 PM. | Privacy Policy
|