Can I combine an EditItemTemplate and InsertItemTemplate?

P

pjbates

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
 
D

Dan Vogt

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.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top