Saturday, March 24, 2012

validation in datagrid

Hi guys!

I am getting trouble to put validation in the datagrid. Could you please help me? I have two fields in datagrid, one is age column and another is sex. For both column i have kept the textbox. I have used template column for both. Now how can i validate the age field with numeric only and sex field with character only?. I am using Asp.net 2.0 and C#.

I would appreciate your help.

Thanks,

Use compare validator, and put those validation next to your text boxes.

<EditItemTemplate>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator" ControlToValidate="TextBox2"></asp:CompareValidator>
</EditItemTemplate>

No comments:

Post a Comment