Solved

datagrid losing controls on postback

Posted on 2007-11-16
1
555 Views
Last Modified: 2012-06-27
I have a datagrid that auto generates columns set to TRUE.  The general layout of this grid is as follows:

Company 1  |   Company 2 |  Company 3 | Company 4 ....
textbox                 DDL             DDL                 DDL
textbox                 DDL             DDL                 DDL
textbox                 DDL             DDL                 DDL
etc..

the reason im using auto generate is because the column headers are names of companies, and depending on the data that i get back, there will be a variable amount of columns(companies).

so i simply generate a datatable with the correct formating, bind it to the datagrid's datasource,
then on ItemDataBound, i dynamically add controls to the cells which will container either a dropdownlist with data in it, or a textbox (each cell will depend on conditions)

all of this works, however, when i postback on anything, the columns stay, but i lose all my controls.  even if i have it re add those controls on every postback, then i still lose the state of their selected values.
the dropdownlists in the grid do not have autopostback set, so we are posting back on other parts of the page.

is there anything that can be done thats relatively simple?
0
Comment
Question by:mocaiv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 20301298
because of the page lifecyle and when thing like controls and their values get put into viewstate...dynamic controls can get tricky....when you add the controls in ItemDataBound, try wrapping that in an ispostback check...make sure you don't re-add or re-bind the dynamic controls when it is a postback....it might still not be in the correct part of the page lifecycle...but see if it changes your results...
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LINQ Select all records by MAX data syntax help 1 51
Asp.Net Session Question 2 49
Json and ajax 1 44
asp.net mvc5 6 34
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question