Groups | Blog | Home
all groups > asp.net > may 2006 >

asp.net : Input validation on detailsview


Kjell Arne
5/31/2006 11:45:01 PM
Hi!

I have a detailsview control in a webpart with some templated fields on. I
set the ValidationGroup property to som value on these fields to distinguish
from other web parts on the page. However, I'm not able to set the same
ValidationGroup on the submit controls on the detailsview. Those
linkbuttons(update, insert) are auto generated now.

1. Is it possible to set ValidationGroup on the detailsview?
2. How would I go about implementing the linkbuttons myself? Could you
please provide an example. Want the same functionality as the build in
linkbuttons give me.
3. Any other way (best practice)?

Thanks in advance.

Brock Allen
6/1/2006 4:36:51 PM
You can provide a template for the buttons and as long as you assign well-known
CommandName properties to the Button's then they'll behavor the same. The
well-known values are: "Edit", "Update", "Cancel", "Delete" and "New", IIRC.

-Brock
http://staff.develop.com/ballen


[quoted text, click to view]

Kjell Arne
6/2/2006 8:20:01 AM
Can you please provide some more details?
The detailsview is already using templates for the fields (ItemTemplate and
EditItemTemplate based on IBindableTemplate).

If I set AutoGenerateInsertButton = false, and create my own button with
CommandName = "New", wouldn't the detailsview provide the Insert (without
ValidationGroup property set) and Cancel buttons for me? I don't see how I
can replace all linkbuttons with my own implementation. I fail to see the
template here.

Code sample?

Thanks for your reply by the way


!
[quoted text, click to view]
Brock Allen
6/2/2006 3:58:32 PM
Something like this:

<asp:DetailsView runat="server" ..... >
<Fields>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" Text="Edit" CommandName="Edit" />
</ItemTemplate>
<EditItemTemplate>
<asp:Button runat="server" Text="Update" CommandName="Update"
ValidationGroup="YourValGroup" />
<asp:Button runat="server" Text="Cancel" CommandName="Cancel"
/>
</EditItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>

-Brock
http://staff.develop.com/ballen


[quoted text, click to view]

Kjell Arne
6/26/2006 2:04:02 AM
Thank you Allen! Worked like a charm!

[quoted text, click to view]
AddThis Social Bookmark Button