Archive for September, 2015

Apply Formatting in formula in crystal report

If you want to apply condition base formatting in crystal report, you can use below method for that.

if (IsNumeric({Student.Marks})) Then
if({Student.Marks} >= 40) then
crbold   //font bold – PASS
else
crregular //font regular – FAIL
else
crregular //if non-numeric/empty/NULL make the font regular – FAIL
=============================================================
To change the font style dynamically according to value, use this expression in your expression

=Format(First(Fields!Field_value.Value, “ABCDEFG”),”BOLD”)

Advertisements

Hyperlinked Images in ASP.NET GridView (Open content in new page)

Solution : 1

TemplateField with Hyperlink and img Element

<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink runat=”server” NavigateUrl='<%# Eval(“PAGE_Or_PDF_URL”) %>’
Target=”_blank”>
<img src='<%# Eval(“Image_URL”) %>’ alt=”PDF IMAGE” />
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>

Solution : 2
TemplateField with ImageButton

<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton runat=”server” ImageUrl='<%# Eval(“Image_URL”) %>’
PostBackUrl='<%# Eval(“Target_URL”) %>’ AlternateText=”Alternate Text” />
</ItemTemplate>
</asp:TemplateField>
Solution : 3

TemplateField with Javascript
<asp:TemplateField>

<asp:ImageButton ID=”ImageButton1″ runat=”server” ImageUrl='<%# Eval(“Image_URL”) %>’ OnClientClick='<%# String.Format (“javascript:return openTargetURL(\”{0}\”)”, Eval(“Target_URL”)) %>’ AlternateText=”Alternate Text” />

</asp:TemplateField>

Disable All validator on page from server side in asp.net

For VB.NET
For Each vValidator As BaseValidator In Page.Validators
vValidator.Enabled = False
Next
For C#
foreach (BaseValidator vValidator in Page.Validators)
{
vValidator.Enabled = false;
}

MouseOver background color effect in gridview

Solution : 1

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(“onmouseover”, “this.originalcolor=this.style.backgroundColor;” + ” this.style.backgroundColor=’#0090CB’; this.style.color = ‘white'”);
e.Row.Attributes.Add(“onmouseout”, “this.style.backgroundColor=this.originalcolor; this.style.color = ‘black'”);
}
}

Solution : 2

#GridView1 tr.rowHover:hover
{
background-color: Yellow;
font-family: Arial;
font-size:12px;
}

<asp:gridview id=”GridView1″ runat=”server” enableviewstate=”false” rowstyle-cssclass=”rowHover” clientidmode=”Static” />

 

 

Remove the decimal places in Crystal Report

Solution

The easiest way to fix the output is to use the ‘ToText’ function. This allows you to apply formatting – most importantly, remove the decimal places.

totext({Field_Name},0,””)