Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 28th, 2006, 07:02 PM
Authorized User
 
Join Date: Oct 2006
Location: Toronto, Ontario, Canada.
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.

Reply With Quote
  #2 (permalink)  
Old September 27th, 2007, 10:33 AM
Registered User
 
Join Date: Sep 2007
Location: , , .
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

Reply With Quote
  #3 (permalink)  
Old September 27th, 2007, 05:18 PM
Registered User
 
Join Date: Sep 2007
Location: Chico, Ca, USA.
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?
Reply With Quote
  #4 (permalink)  
Old September 27th, 2007, 05:29 PM
Registered User
 
Join Date: Sep 2007
Location: Chico, Ca, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Figured out:

detailsview.UpdateItem(false);
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:29 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.