Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2006, 07:02 PM
Authorized User
 
Join Date: Oct 2006
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Default Moving the new/insert button on DetailsView

I have a GridView and DetailsView on a page, and when I specify
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" ShowDeleteButton="True" /> at the bottom of the DetailsView, I get the 3 normal buttons rendered at the bottom of the DetailsView table it creates.

This seems like poor usability to me. When my user wants to insert a new record, he or she has to first get an existing record into the DetailsView Table, then click on "New". What I would rather have is the "new" button rendered elsewhere on the page, outside the DetailsView and GridView tables. I can see what the DetailsView is creating in the HTML code ... it looks like this:
<a href="javascript:__doPostBack('DetailsView1','Edit $0')">Edit</a>

I could probably just copy this elsewhere on the page, but that is a pretty bad coding practice.

What is the preferred method of creating the button outside the GridView and DetailsView? I tried doing my own <asp:Linkbutton> but either that's not allowed or I don't understand the syntax.

 
Old September 27th, 2007, 10:33 AM
Registered User
 
Join Date: Sep 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can do that using this code:
 detailsview.ChangeMode(DetailsViewMode.Insert)

this put de control in insert mode

 
Old September 27th, 2007, 05:18 PM
Registered User
 
Join Date: Sep 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks jpacev,
It worked like a charm for me.
Any thoughts on invoking [Update] or [Insert] record button?
 
Old September 27th, 2007, 05:29 PM
Registered User
 
Join Date: Sep 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Figured out:

detailsview.UpdateItem(false);





Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting a DetailsView Insert default value jpullam ASP.NET 2.0 Basics 13 April 7th, 2014 02:19 AM
DetailsView Cancel button to redirect firblazer ASP.NET 3.5 Basics 4 June 23rd, 2008 01:23 AM
Insert DropDownList(DetailsView) value toMS Access yukijocelyn ASP.NET 2.0 Professional 0 August 22nd, 2007 09:49 PM
Button on GridView that goes to DetailsView AndrewD ASP.NET 2.0 Basics 0 November 30th, 2005 11:09 AM
moving a button in code goplayoutside VB.NET 2002/2003 Basics 2 April 22nd, 2004 01:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.