I suspect this is an easy or obvious question, but in the book i'm learning from there doesn't seem to be any information on this, and I can't find anything on google - which just means i'm searching for the wrong terms!![]()
How do I add validation controls, such as valid date, nulls not allowed etc onto my detailsView control and my gridView control when the user is in edit 'mode' (?)
Cheers,
Daf
You can make Template Column in Gridview, On that template column in edit mode you can put a validation check to a textbox or what ever control you are using. If you need further help please tell me.
So there's no drag and drop solution?
If I make a template column for almost every field I have, won't that ruin the ability to have an edit mode, or require some complex programming to get that mode back?
Cheers, daf
in fact yes you can use the validation controls
these are all made up for you with features that make appear a text near the control that do not pass validation
and a summary.
but again these need to be in a template field, but regroup in only one validationgroup.
so look at :
RequiredFiledValidator
RangeValidator
RegularExpressionValidator
CompareValidator
CustomValidator
and ValidationSummary Controls for more information about these control
thanks for the reply!
if I use the template field don't I loose the neat editing ability for the gridView? becuase I have to add databinding fields instead?
Hi:
daffydowden:
if I use the template field don't I loose the neat editing ability for the gridView?
We can simply use two-way Data Binding:
<Columns>
<asp:TemplateField>
<ItemTemplate>This Template is for ReadOnly mode</ItemTemplate>
<EditItemTemplate>This Template is for Edit mode.<br />
Generally we do this for two-way Data Binding:<br />
<asp:TextBox ID="TextBox4" runat="server" Text='<%#Bind("field_name") %>'></asp:TextBox>
<br/>
Add your validation control here
</EditItemTemplate>
</asp:TemplateField>
</Columns>
If your problem isn't solved, please inform us.
Regards
No comments:
Post a Comment