473,385 Members | 1,890 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,385 software developers and data experts.

Can I combine an EditItemTemplate and InsertItemTemplate?

Hi,

I've been using the GridView and DetailsView controls for a while, and
I'm beginning to get annoyed by the redundancy of EditItemTemplate and
InsertItemTemplate in many cases.

In the following code, both edit and insert templates are identical. It
would be great if I could define a generic template to be used for both
edits and inserts. I know that there are many situations where the edit
and insert templates will differ, but for the simple cases it would be
nice to use a single template.

Is there a work around for this?

Thanks

<asp:TemplateField HeaderText="EndDate" SortExpression="EndDate">
<ItemTemplate>
<asp:Label ID="Label_EndDate" runat="server"
Text='<%# Bind("EndDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox_EditEndDate"
runat="server" Text='<%# Bind("EndDate") %>' />
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox_InsertEndDate"
runat="server" Text='<%# Bind("EndDate") %>' />
</InsertItemTemplate>
</asp:TemplateField>

Peter

Nov 19 '05 #1
1 3093
Hey..i think i have a solution to your problem. You can nest the
Templates inside of each other like this:

<EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox id="txt" runat="server"/>
</InsertItemTemplate>
</EditItemTemplate>

I have tried this method on one page so far and have had no problems
yet. Hope this helps.

*** Sent via Developersdex http://www.developersdex.com ***
May 2 '06 #2

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

Similar topics

15
by: NH | last post by:
How can I only display the textbox I have in an EditItemTemplate based on the value in another cell in the row? i.e I only want users to edit one of the cells based on the value in another...
1
by: Dan Sikorsky | last post by:
My ASP.Net 2.0 FormView has an EditItemTemplate, an InsertItemTemplate and an ItemTemple. When the page first loads, the ItemTemplate shows with an Edit button. If the user clicks the Edit button,...
0
by: hooterbite | last post by:
The forms in Insert and Edit are almost identical, and each fom field has the same name in each template. For example, I have a txbName in the InsertItemTemplate and a txbName in the...
0
by: Cas | last post by:
Hi, I want to create a InsertItemTemplate in a detailsview (only insertmode)programmatically. I first defined a Template, then i tried to create within that templatefield a InsertItemTemplate...
0
by: Dan | last post by:
Issue making textbox visible based on specific input from a radio button list in an EditItemTemplate I want to setup a gridview that when in edit mode and when the user selects "Other" from a...
2
by: npei72 | last post by:
I have a simple Formview like this: <%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true" CodeFile="HelloWorld.aspx.cs" Inherits="_HelloWorld"%> <html> <body> <form...
2
by: Steve Hershoff | last post by:
Hi everyone, I have a DataGrid with several TemplateColumns. One of these columns has an EditItemTemplate that contains an ASP.Net DropDownList. I'm catching this DropDownList's...
0
by: dch | last post by:
I have a GridView, and when I click Edit, it is firing the OnRowEditing event ,and I am setting the edititem index, but it keeps displaying the ItemTemplate fields instead of the EditItemTemplate. I...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.