Creating Dynamic FormView Templates

  • Thread starter Stephen Hatfield
  • Start date
S

Stephen Hatfield

Is it possible to create FormView templates (EditItemTemplate,
InsertItemTemplate, ItemTemplate) dynamically by calling a separate class
file to generate the template. My attempts at this have been unsuccessful. I
am working in the ContentPlaceHolder on a page using a masterpage. I have
tried adding a PlaceHolder tag and putting the FormView control within but
still no luck. I have seen the example for doing this within a web page but
not by calling the ITemplate class within a different .cs file.

Thank you!
Steve
 
S

Stephen Hatfield

Thanks for your reply Philip! I have no problem generating templates for
Columns in a GridView. I am having problems doing the same with a FormView.

Steve
 
P

Phillip Williams

Hi Stephen,

I just added another demo within the same section on my website for the
FormView.
 
Joined
Oct 20, 2012
Messages
1
Reaction score
0
Update in FormView does not persist data

Philip,
I was checking the FormView sample on your website, However, the code there does not seem to be complete. e.g, I could not see where DataBound occurs.

My current issue is that
I add the ItemTemplate, and EditItemTemplate during OnInit stage as in your sample.

ItemTemplate has an edit button, then in order to switch to the Edit mode,
I have to do

this.MyFormView.ChangeMode(FormViewMode.Edit);
this.MyFormView.DataBind();

in OnItemCommand, (this part is not shown in your sample either)

However, the timing when DataBind occured in OnItemCommand is already too late. Although formview correctly displayed the edit mode, any updated value cannot be saved. In fact, I even could not receive Update command in OnItemCommand. Does my question makes sense to you?
Thank you in advance for your help!

Chen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,516
Members
44,991
Latest member
Josephnag

Latest Threads

Top