Trek Innovations

Thoughts For You

Archive for the 'C#' Category

Regular Expression To Allow only 2 Decimal Places in the Textbox Control

Regular Expression To Allow only 2 Decimal Places in the Textbox Control :

In order to allow only 2 decimal places in the textbox use the regular expression validator. In the validator control there will be a property called ValidationExpression,use this property to assign the valid expression as shown below.

<asp:TextBox ID=”_tbCost” runat=”server” TabIndex=”4″></asp:TextBox>

<asp:RegularExpressionValidator ID=”_ReqExpressionPhoneNo” runat=”server” ErrorMessage=”Enter numbers & ‘.’ only,should contain only 2 decimal places.” ControlToValidate=”_tbCost” Display=”none” ValidationExpression=”(?!^0*$)(?!^0*\.0*$)^\d{1,18}(\.\d{1,2})?$”>

</asp:RegularExpressionValidator>

Read more

Share This Post No comments

Export NestedGridView To Excel

In order to export the nested gridview please follow the code below.

SalesReport.Ascx

<%@ Control Language=”C#” AutoEventWireup=”true” Codebehind=”SalesReport.ascx.cs”
Inherits=”Epod.UserControls.SalesReport” %>
<div id=”divgridView” class=”grid”>
<asp:GridView ID=”gvProducts” runat=”server” AllowSorting=”false” AllowPaging=”false” AutoGenerateColumns=”False”
CellPadding=”4″ GridLines=”None” ShowFooter=”false” OnRowCommand=”gvProducts_RowCommand”
Width=”100%”>
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign=”Left”>
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID=”_btnExpandandCollapse” runat=”server” Text=”<img src=’../images/expand.gif’ alt=’Expand to see detailed report’ border=’0′ />”
CssClass=”GridViewDataHyperLink” CommandArgument=’<%# Container.DataItemIndex %>’
CommandName=’<%# Eval(“ProductId_pk”) %>’ ToolTip=”Expand to see the detailed report”></asp:LinkButton>&nbsp;&nbsp;
<asp:Label ID=”_lblEmployeeName” Font-Bold=”true” runat=”server” Text=’<%# Eval(“ProductName”) %>’></asp:Label>

Read more

Share This Post No comments