Input validation on detailsview

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.

Kjelli
 
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
 
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


!
 
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
 
Thank you Allen! Worked like a charm!

Brock Allen said:
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
 
Back
Top