473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Detailsview: Is it possible to share templatefields

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
Sep 25 '08 #1
3 947
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

"Ole Kirkholt" wrote:
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
Sep 25 '08 #2
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

"cmeek1_1999" wrote:
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

"Ole Kirkholt" wrote:
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
Sep 26 '08 #3
Dit you use a FormView1.DataBind()?
In the PageLoad I mostly DataBind all controls:
if (!IsPostBack)
{
FormView1.DataBind();
}
"Ole Kirkholt" wrote:
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

"cmeek1_1999" wrote:
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

"Ole Kirkholt" wrote:
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
Sep 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: sck10 | last post by:
Hello, I am using the code below to set the values of a DetailsView template field using FindControl. My question is how would you find a control if its a Boundfield control? For example,...
0
by: Andrew | last post by:
Does anyone know of a good example for creating TemplateFields in a DetailsView at runtime with data binding? Thanks, Andrew
2
by: William LaMartin | last post by:
Is there a way to increase the width of the text boxes for the DetailsView in edit or insert mode? When I put the control in either edit or insert mode, the text boxes to type the new text are...
2
by: Not Me | last post by:
Hi, I've seen this prob in a few places but the explanations/solution wasn't up to my understanding! I have a detailsview, with an insert button that works fine when there is already data in...
1
by: vbnetdev | last post by:
I need to customize the DetailsView New record (insert) so that it gets the maximum value of ROWID and adds 1, places that value in the textbox and makes it read only. Also, I have a field...
5
by: clickon | last post by:
This is driving me nuts, it is such a simply thing to do but i cannot for the life of me work out how you are suposed to do it. I want to update the data in DropDownListB based on what is...
5
by: Mike P | last post by:
The default format for the DetailsView control is for there to be a row per field. Is it possible set it to show more than one column per row (see below)? ID ... Name ......
1
by: Michael Gross | last post by:
Hello I have a GridView, and a DetailsView to edit the data. In the DetailsView I have two TemplateFields with a DropDownList in each TemplateField. Now I want that when the user selects an item...
1
by: Mark Stafford | last post by:
I am attempting to use a DetailsView control to view some data where the fields returned by the database are determined at runtime. I create the TemplateFields on the fly using a class that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.