Detailsview: Is it possible to share templatefields

  • Thread starter Thread starter Ole Kirkholt
  • Start date Start date
O

Ole Kirkholt

Hello

I'm starting on my first asp.net project.
I'm using VS2008sp1 and .Net 3.5

I'm trying to create a page for inserting/editing a single databaserecord

I need both multiline textboxes, check- and listboxes.
To do that I need templatefields, right ?

Is there a way to share the same templatefield between inserting and editing,
so I don't have til make everything (including validation controls) twice ?

Best Regards

Ole
 
If you do not specify an inserting template, the editing template will be used.
The save button needs an "insert" or "update" string, so you can create
a protected property UpdateOrInsert which returns
FormView1.CurrentMode != FormViewMode.Insert ? "Update" : "Insert";
Specify CommandName='<%# UpdateOrInsert %>' for the save button.

Regards,

Carlo Mekenkamp
 
Hello again

I have tried this, but it is not working on inserts.

When I want to insert a record by setting the formview's defaultmode to
Insert, the property isn't read, and therefore the commandtext isn't updated.

Is there any other way/event that can be used to set the CommandText of a
linkbutton, of to force the form til save the new record ?¨

Best Regards

Ole Kirkholt
 
Dit you use a FormView1.DataBind()?
In the PageLoad I mostly DataBind all controls:
if (!IsPostBack)
{
FormView1.DataBind();
}
 
Back
Top