473,569 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I combine an EditItemTemplat e and InsertItemTempl ate?

Hi,

I've been using the GridView and DetailsView controls for a while, and
I'm beginning to get annoyed by the redundancy of EditItemTemplat e and
InsertItemTempl ate 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:TemplateFi eld HeaderText="End Date" SortExpression= "EndDate">
<ItemTemplate >
<asp:Label ID="Label_EndDa te" runat="server"
Text='<%# Bind("EndDate") %>'></asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:TextBox ID="TextBox_Edi tEndDate"
runat="server" Text='<%# Bind("EndDate") %>' />
</EditItemTemplat e>
<InsertItemTemp late>
<asp:TextBox ID="TextBox_Ins ertEndDate"
runat="server" Text='<%# Bind("EndDate") %>' />
</InsertItemTempl ate>
</asp:TemplateFie ld>

Peter

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

<EditItemTempla te>
<InsertItemTemp late>
<asp:TextBox id="txt" runat="server"/>
</InsertItemTempl ate>
</EditItemTemplat e>

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
1602
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 cell.... Should I do this in the ItemDataBound event of the datagrid...something like... If e.Item.Cells(8).Text = "2" Then dont allow the textbox...
1
2547
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, the postback loads the EditItemTemplate, but with NO focus on any control on the EditItemTemplate. How can I set the focus to the first textbox on...
0
1181
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 EditItemTemplate. My project has been fine until today, and now it says that " The ID 'txbName' is already used by another control." I did not change anything in...
0
3237
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 (but i don't know how), and finally a textbox. I did this: (Detailsview1 is defined in the .aspx file) Dim tfield As TemplateField
0
3656
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 radiolist that a text box will appear and the user can input text. I can get the textbox to appear after selecting other in the radiolist; however,...
2
5690
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 runat="server"> <asp:FormView DataSourceID="myODS" ID="ItemFormView"
2
7305
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 SelectedIndexChanged event. I also have another TemplateColumn, with a RequiredFieldValidator that validates a TextBox in the column. It all looks like this,...
0
1133
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 have done this before, but I can't figure out why it is ignoring the EditItem Template. I have my code below. Basically, I am storing a "work"...
4
2886
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 is not a null value. I am not using any code behind (C#) to bind the data or manipulate the data. I have read that when there is a null value in...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.