468,766 Members | 1,379 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,766 developers. It's quick & easy.

Datalist Dynamic Template Loading Problem

Hello-
I am failry new to asp.net but have been coding in general for a while.

I have a datalist whos templates are built on the fly.
In the Page_Init sub, based on a certain value, certain external
controls are assigned as the ItemTemplate and the EditTemplate.

1)If I only assign these templates if its not a post back, the datalist
is blank when I click on the edit button in the datalist.

2) If I let the page_init assign these templates everytime there is a
postback, the edit datalist renders correctly (a few drop downs and a
textbox).
But when I click my update button, I then try to a FindControl on my
datalist with a control I know is in the edit template but it gives me
this error:"Object reference not set to an instance of an object. "

Has anyone come across this?

Thanks in advanced!
MB

Nov 19 '05 #1
3 1505
> 1)If I only assign these templates if its not a post back, the
datalist is blank when I click on the edit button in the datalist.


You need to recreate any and all dynamic controls upon every postback. You
typically do this inside of CreateChildControls (a virtual from the Control
base class). If you recreate the controls properly, then it will behave as
if they were done statically in the ASPX file.

-Brock
DevelopMentor
http://staff.develop.com/ballen


Nov 19 '05 #2
If any one else is interested, I found this article:
http://lab.msdn.microsoft.com/Produc...7-264a1456ba8f

Basically:
" When the FormView's EditItemTemplate is dynamically loaded using
LoadTemplate, the attached data source control is passed zero
parameters when updating the record."

According to the doc, this problem is:

"Status: Closed
Resolution: Postponed"

Nov 19 '05 #3
Thanks Brock, I'll give it a shot.
I did not see your reply before I posted my previous reply.

Thanks Again
MB

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Fabrizio | last post: by
4 posts views Thread by Yan Wang | last post: by
1 post views Thread by Scott Schluer | last post: by
10 posts views Thread by Bharat | last post: by
1 post views Thread by Ed Chiu | last post: by
3 posts views Thread by Mirek Endys | last post: by
reply views Thread by =?Utf-8?B?Y2luZHk=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.