Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Datagrid Template Columns 1

Status
Not open for further replies.

bjd4jc

Programmer
Nov 8, 2001
1,627
US
I need a datagrid that looks like similar to this:
[tt]
|-------------------------------|
| | MEAN | STD | SI |
|-------------------------------|
|Row 1 |[ ] | [ ] | [ ] |
|-------------------------------|
|Row 1 |[ ] | [ ] | [ ] |
|-------------------------------|
|Row 1 |[ ] | [ ] | [ ] |
|-------------------------------|
|Row 1 |[ ] | [ ] | [ ] |
|_______________________________|
[/tt]

However, I need the columns to be dynamically created. I am using code from here to create the columns dynamically.

The problem is when you add a column to the datagrid at run-time, per the documentation, it does not get added to the viewstate of the datagrid. This creates a problem for me because there is no way to get the values the user entered into the grid at post back (at least no way I can figure out).

Can someone help me out with ideas on how to make this happen?
 
As long as ViewState is enabled for the DataGrid and the Page, any dynamic controls that are added to the page should retain their values as long as you create those controls every time the page is loaded. Are you making sure you are doing this on each load of the page?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Okay. This seems to work. It doesn't make much sense to me, however. I don't understand how if I re-create the control it has the value it had before. Care to help explain it some?

 
Well, the values do get added to ViewState when they are posted back to the server but if you don't recreate the controls, they can't be added back to the control as it doesn't exist.

I'm sure there's probably a more technical explanation of this but I think that's the basic idea!


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top