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 columns are not maintaining state 1

Status
Not open for further replies.

KnotGoblin

Technical User
Jan 4, 2005
77
US
I am adding columns to a datagrid at runtime. However, after a post back the dynamically added columns are gone.

Note: data is not bound to the grid on the initial page load, so it wouldn't help just putting the procedure to add the columns in the page_load sub (i don't think.)
 
However, after a post back the dynamically added columns are gone.
That's what should happen. You will have to re-create them each time the page loads.


____________________________________________________________

Need help finding an answer?

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

 
i am currently building dynamic pages. From all the examples I have seen they recommend adding the contols in the page_init event. This way viewState will remain.
 
I'm not sure if that will work for me.

maybe i should clarify what I am actually doing.

I have a datagrid that shows all the individual projects for a job. Another datagrid shows a Bill of Materials for each project. That is where i am dynamically adding the columns. I am adding purchase order info to each entry in the bill of materials. (its rather complicated. otherwise, i would let SQL take care of it.) So if the user selects another project they get the bill of materials for that project (So the BOM datagrid has to be "re-bound" when a new project in selected.) my method of adding columns probably only works because the columns disappear after a post back.

So the problem is: when ever an event that triggers a postback (other than the selection to view a project) the columns disappear.

I don't know how the use the page_init event to bind the data.
 
If i can figure out what triggered the post back. i could determine what needs to bind the data--the page_load event or the event handler that binds a new project to the datagrid.

so how can i figure out what control or event triggered the postback?
 
Thanks ca8msm.

I think this will help a lot.

Since the control i was looking for was a button in a datagrid button column I had to convert it to a template column and give the button an ID. otherwise the control has no ID except a clientID.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top