Make a new column in datatable c# using existing columns or hardcode values, using expression

Filed in Uncategorized Leave a comment

Merge two or more columns in c# datatable

ds.Tables[1].Columns.Add(“NEWCOLUMNNAME”, typeof(System.String), “COL1+ ‘-’ + COL2″);

You can make any complex sql expression.

Recover MS Office files if you mistakenly press “No” when asked to save.

Filed in Uncategorized Leave a comment

Below is the path form where you can recover auto saved copy of office files. It is very helpful if you mistakenly press “No” on close dialogue.


PTCL Freedom Unlimited Package in comparison with Double Up Unlimited Package

Filed in Uncategorized Leave a comment

Below is the analysis on new PTCL Freedom Unlimited Package in comparison with old Double Up Unlimited Package. I did it for the DSL subscribers and obviously some plus and minus are possible in it.

With 1 MB DSL 

Total Bill Rs. 1750: New Package with 1 MB DSL (1200 DSL, 250 Fixed, 300 Tax approx)
Total Bill Rs. 2200: New Package with 1 MB DSL and (Smart TV RS.449)
Total Bill Rs. 2330: Double Up Package charges for same

With 2 MB DSL 

Total Bill Rs. 2050: New Package with 2 MB DSL (1500 DSL, 250 Fixed, 350 Tax approx)
Total Bill Rs. 2500: New Package with 2 MB DSL and (Smart TV RS.449)
Total Bill Rs. 2650: Double Up Package charges for same

Smart TV facility charges is free in Double up package and if you are paying any device charges that would be added in the above amount. PCTL to PTCL Local, Nation wide and Vfone calls are unlimited in the above packages. Standard rates would apply for the calls on Mobile, International or any other network. The only draw back of this new Freedom Unlimited Package is that cell phone calls from your land line in Double Up Unlimited package is half rated from standard. But you can add Mobile bundle package with it.

Be aware !!! Once you opt for this new package you can’t come back to Double Up Unlimited package.

There is some thing good for the simple land line customers also (without DSL)  who do PCTL to PTCL Local, Nation wide and Vfone calls. Around in Rs 700 you can do it unlimited.

P.S: I tried my best in calculating above rate but I am not responsible for any any mistake in above calculation.

Referene: PTCL official website

Gridview select all checkbox, row color change on selection/hover, row delete client side

Filed in Uncategorized Leave a comment

Set Hex code of color in c#

Filed in Uncategorized Leave a comment

e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml(“#CEFFCE”);

Calling a custom function in gridview template column

Filed in Uncategorized Leave a comment

Text=’<%# MakeFullName(Convert.ToString(Eval(“FirstName”)),Convert.ToString(Eval(“LastName”))) %>’

enable disable validators on drop down selection change client side

Filed in Uncategorized 1 Comment

JavaScript function:

function setValidations() {

var ddlst = document.getElementById(“<%=ddlPiggyback.ClientID%>”);

var Text = ddlst.options[ddlst.selectedIndex].text;

if (Text == ’0′) {

ValidatorEnable(document.getElementById(“<%=rfvPiggybackComments.ClientID%>”), false);


else {

ValidatorEnable(document.getElementById(“<%=rfvPiggybackComments.ClientID%>”), true);



In drop down (aspx side)

<asp:DropDownList ID=”ddlPiggyback” runat=”server” onchange=”setValidations();”>





Convert string value to enum

Filed in Uncategorized Leave a comment

(Enums.RequestType)Enum.Parse(typeof(Enums.RequestType), rblRequestType.SelectedItem.Text)

Setting a text in aspx file via getting value from global resource file

Filed in Uncategorized Leave a comment

Text=”<%$ Resources:Common, No_Record_Found %>”

Where Common is the resource file name and No_Record_Found is Key name in Common.resx file

AJAX Toolkit File upload asynch asp:AsyncFileUpload

Filed in Uncategorized Leave a comment

It is perfect control if you don’t have to update any label or gridview in it .cs method. It perfectly did any DB operations but won’t update the html.

<asp:AsyncFileUpload OnClientUploadError=”uploadError” OnClientUploadComplete=”uploadComplete”

runat=”server” ID=”AsyncFileUpload1″ Width=”400px” CompleteBackColor=”White”

UploadingBackColor=”#CCFFFF” ThrobberID=”imgLoader” OnUploadedComplete=”FileUploadComplete”

FailedValidation=”False” />

<asp:Image ID=”imgLoader” runat=”server” ImageUrl=”~/images/loader.gif” />

<br />

<asp:Label ID=”lblMesg” runat=”server”></asp:Label>

FileUploadComplete method:

string strfilename = System.IO.Path.GetFileName(AsyncFileUpload1.PostedFile.FileName);

string strFullPath = Server.MapPath(Constants.General.RequestAttachmentsFolderName + lblRequestID.Text + “/”);

if (!System.IO.Directory.Exists(strFullPath))




AsyncFileUpload1.SaveAs(strFullPath + strfilename);


<script type=”text/javascript”>

function uploadComplete(sender) {

$get(“<%=lblMesg.ClientID%>”).style.color = “green”;

$get(“<%=lblMesg.ClientID%>”).innerHTML = “File Uploaded Successfully”;



__doPostBack(‘<%= Button1.ClientID %>’, ”);



function uploadError(sender) {

$get(“<%=lblMesg.ClientID%>”).style.color = “red”;

$get(“<%=lblMesg.ClientID%>”).innerHTML = “File upload failed.”;


function clearContents() {

var AsyncFileUpload = $get(“<%=AsyncFileUpload1.ClientID%>”);

var txts = AsyncFileUpload.getElementsByTagName(“input”);

for (var i = 0; i < txts.length; i++) {

if (txts[i].type == “text”) {

txts[i].value = “”;

txts[i].style.backgroundColor = “white”;





Useful links