Saturday, March 24, 2012

Validation textbox at editble mode?

Hi,
when I clicked edit button, the Quantity Field displayed value into a textbox at selected row of datagrid.
the question is: how can I validate this textbox?

thanks.You have to use a TemplateColumn. Then, just add the validation control to the TemplateColumn's EditItemTemplate. Assume the field name is SSN, you'd have something like:


<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "SSN") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" id="SSNValue" Text='<%# DataBinder.Eval(Container.DataItem, "SSN") %>'></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ControlToValidate="SSNValue" ErrorMessage="..." />
</EditItemTemplate>
</asp:TemplateColumn>

That should about do it!

No comments:

Post a Comment