DetailsView Default Mode

O

Olivier Matrot

Hi all,
I'm working with a detailsview control which default mode is set to
'Insert'.
This control has AutogenerateInsertButton set to 'yes'.

So basically, I'm always in insert mode, and I have only one field to
display. The problem is that there is an auto generated 'Cancel' button
which has no means (Cancel buttons revert to the default mode that is Insert
!). I would like to delete this button at runtime. Is it possible without
switching to AutogenerateInsertButton = false ?
TIA.
 
B

bhavesh

i am not sure but u can try something like following.

(1) see page's view source with cancel button.

(2) find that cancel button and get its id.

(3) now in code behind , try to find that button findcontrol method of
detailsview.

(4) and convert it into button with ctype. and u can get access to that
button.

may this will help u .
 
W

Walter Wang [MSFT]

Hi Olivier,

Internally, the DetailsView dynamically creates a CommandField and set its
properties ShowInsertButton, ShowDeleteButton, ShowEditButton according to
the DetailsView's properties AutoGenerateInsertButton,
AutoGenerateDeleteButton, AutoGenerateEditButton. The CommandField has an
extra property called ShowCancelButton which could let you control whether
or not to show the Cancel button. Unfortunately, the CommandField is
internal to the DetailsView and there's no public property to retrieve it.

However, DetailsView let you provide a CommandField in the Fields
collection. You could turn off all those AutoGenerate* properties and
provide a CommandField yourself:

<asp:DetailsView ID="detail1" runat="server" DefaultMode="Insert"
AutoGenerateInsertButton="false" AutoGenerateEditButton="false"
AutoGenerateDeleteButton="false">
<Fields>
<asp:CommandField ShowInsertButton="true"
ShowCancelButton="false" />
</Fields>
</asp:DetailsView>


Hope this helps.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top