Detailsview: Is it possible to share templatefields

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
 
C

cmeek1_1999

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
 
O

Ole Kirkholt

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
 
C

cmeek1_1999

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

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,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top