When using the Grid Web Controld a lot of times I find myself needing to customize the edit functionality to use validation. The following are the procedures that I use to customize the Data Grid Web Controld.
In order to implement a customization in a datagrid you need to implement a template
<asp:TemplateColumn HeaderText="Gift Amount">
<itemtemplate>
<asp:label id="lblAward_Amount" text='<%# DataBinder.Eval(Container.DataItem, "Gift_Amount", "{0:c}") %>' Runat="server" />
</itemtemplate>
<edititemtemplate>
<asp:textbox ID="txtGift_Amount2" text='<%# DataBinder.Eval(Container.DataItem, "Gift_Amount", "{0:c}") %>' runat="server" />
<asp:regularexpressionvalidator id="Regularexpressionvalidator1" runat="server" ControlToValidate="txtGift_Amount2"
ErrorMessage="Money Values only example 20.00 no commas!" ValidationExpression="\d*.\d{2}"></asp:regularexpressionvalidator></asp:boundcolumn>
</edititemtemplate>
</asp:TemplateColumn>
To access this in the code behind you must using the following:
// This will access the control inside the data grid.
tempGiftAmount = (((TextBox)e.Item.FindControl("txtGift_Amount2")).Text);
Software engineering and business solutions blog featuring SaaS reviews, automation tools, and business insurance guides. Buyer-intent content designed to drive high-quality traffic and conversions.
Subscribe to:
Post Comments (Atom)
Best Docker Containers for Home Lab: An Informational Guide for US Business Owners
Best Docker Containers for Home Lab Introduction Docker containers have become a popular technology for managing applications in isol...
-
How to clear SharePoint People Picker suggestion cache If you have been SharePoint Site owner long enough, you would have definitely ...
-
Getting the following error (Figure 1): Server Error in '/' Application. ID4014: A SecurityTokenHandler is not registered to ...
-
The problem was that the remote connection needed to utilize Named Pipes, but in order to utilize Named Pipes both the machine hosting the i...
No comments:
Post a Comment