Home All Groups Group Topic Archive Search About
Author
23 Jan 2007 10:12 AM
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.

Author
23 Jan 2007 3:29 PM
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 .


Olivier Matrot wrote:
Show quoteHide quote
> 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.
Author
24 Jan 2007 3:10 AM
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 (waw***@online.microsoft.com, 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.
Author
26 Jan 2007 1:31 PM
Olivier Matrot
Hi Walter.
This is working well.
Thanks for that.

Show quoteHide quote
"Walter Wang [MSFT]" <waw***@online.microsoft.com> wrote in message
news:FR1ToU2PHHA.2024@TK2MSFTNGHUB02.phx.gbl...
> 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 (waw***@online.microsoft.com, 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.
>