function iggrdGridKitMgmt_ColumnHeaderClickHandler(gridName, columnId, button)
{
// debugger;
var myCol = igtbl_getColumnById(columnId);
var myGrid = igtbl_getGridById(gridName);
if(myCol.Key != "ChkAll" && myCol.Key != "Uncheck All")
{
return;
}
if (myCol.Key == "ChkAll")
{
for (i = 0; i < myGrid.Rows.length; i++)
{
myGrid.Rows.getRow(i).getCellFromKey("ChkAll").setValue(1);
}
myCol.Key = "Uncheck All";
myCol.HeaderText= "Uncheck All";
}
else
{
for (i = 0; i < myGrid.Rows.length; i++)
{
myGrid.Rows.getRow(i).getCellFromKey("Uncheck All").setValue(0);
}
myCol.Key = "ChkAll";
myCol.HeaderText = "Check All";
}
}
//If template Column and inside we have check box
function iggrdGridKitMgmt_ColumnHeaderClickHandler(gridName, columnId, button)
{
//debugger;
var myCol = igtbl_getColumnById(columnId);
var myGrid = igtbl_getGridById(gridName);
if(myCol.Key != "ChkAll" && myCol.Key != "UncheckAll")
{
return false ;
}
if (myCol.Key == "ChkAll")
{
for (i = 0; i < myGrid.Rows.length; i++)
{
myGrid.Rows.getRow(i).getCellFromKey("ChkAll").getElement('chkSelect').all[0].checked=true;
}
myCol.Key = "UncheckAll";
myCol.HeaderText= "Uncheck All";
}
else
{
for (i = 0; i < myGrid.Rows.length; i++)
{
myGrid.Rows.getRow(i).getCellFromKey("UncheckAll").getElement('chkSelect').all[0].checked=false;
myGrid.Rows.getRow(i).getCellFromKey("UncheckAll").Column.Selected = false ;
}
myCol.Key = "ChkAll";
myCol.HeaderText = "Check All";
}
return false ;
}
Wednesday, August 18, 2010
Wednesday, July 21, 2010
Thursday, June 17, 2010
DataTable to CSV
private void exportDataTableToCsv(DataTable formattedDataTable, string filename)
{
DataTable toExcel = formattedDataTable.Copy();
HttpContext context = HttpContext.Current;
context.Response.Clear();
foreach (DataColumn column in toExcel.Columns)
{
context.Response.Write(column.ColumnName + ",");
}
context.Response.Write(Environment.NewLine);
foreach (DataRow row in toExcel.Rows)
{
for (int i = 0; i < toExcel.Columns.Count; i++)
{
context.Response.Write(row[i].ToString().Replace(",", string.Empty) + ",");
}
context.Response.Write(Environment.NewLine);
}
context.Response.ContentType = "text/csv";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + ".csv");
context.Response.End();
}
{
DataTable toExcel = formattedDataTable.Copy();
HttpContext context = HttpContext.Current;
context.Response.Clear();
foreach (DataColumn column in toExcel.Columns)
{
context.Response.Write(column.ColumnName + ",");
}
context.Response.Write(Environment.NewLine);
foreach (DataRow row in toExcel.Rows)
{
for (int i = 0; i < toExcel.Columns.Count; i++)
{
context.Response.Write(row[i].ToString().Replace(",", string.Empty) + ",");
}
context.Response.Write(Environment.NewLine);
}
context.Response.ContentType = "text/csv";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + ".csv");
context.Response.End();
}
Wednesday, June 2, 2010
Apply Styles for row - GridView
protected void grdTemp_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Apply Styles for Header
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[17].Text == "RepeatHeader")
{
e.Row.BackColor = System.Drawing.Color.FromName("#003366");
e.Row.ForeColor = System.Drawing.Color.White;
}
}
{
//Apply Styles for Header
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[17].Text == "RepeatHeader")
{
e.Row.BackColor = System.Drawing.Color.FromName("#003366");
e.Row.ForeColor = System.Drawing.Color.White;
}
}
Tuesday, June 1, 2010
Format Currency
double dblAmt;
string curCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
System.Globalization.NumberFormatInfo currencyFormat = new System.Globalization.CultureInfo(curCulture).NumberFormat;
currencyFormat.CurrencyNegativePattern = 1;
if (dsCash.Tables[0].Rows[0]["Amount"].ToString().Trim() != "")
{
dblAmt = Convert.ToDouble(dsCash.Tables[0].Rows[0]["Amount"].ToString());
lblCashAlternatives.Text = dblAmt.ToString("c", currencyFormat);
}
else
{
lblCashAlternatives.Text = "$0.0";
}
string curCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
System.Globalization.NumberFormatInfo currencyFormat = new System.Globalization.CultureInfo(curCulture).NumberFormat;
currencyFormat.CurrencyNegativePattern = 1;
if (dsCash.Tables[0].Rows[0]["Amount"].ToString().Trim() != "")
{
dblAmt = Convert.ToDouble(dsCash.Tables[0].Rows[0]["Amount"].ToString());
lblCashAlternatives.Text = dblAmt.ToString("c", currencyFormat);
}
else
{
lblCashAlternatives.Text = "$0.0";
}
Saturday, May 15, 2010
Send Mail in C#
using System.Net.Mail;
MailMessage objMessage = new MailMessage();
objMessage.Bcc.Add(dicInputs["Bcc"].ToString().Trim());
objMessage.From = new MailAddress(dicInputs["From"].ToString().Trim());
objMessage.To.Add(dicInputs["To"].ToString().Trim());
objMessage.Subject = dicInputs["Subject"].ToString().Trim();
objMessage.Body = dicInputs["Message"].ToString().Trim();
string[] sAttachments = null;
sAttachments = dicInputs["Attachments"].ToString().Split(',');
for (int intLoop = 0; intLoop <= sAttachments.GetUpperBound(0); intLoop++)
{
strLogOut = strLogOut + "Adding attachment '" + sAttachments[intLoop] + "'";
objMessage.Attachments.Add(new Attachment(sAttachments[intLoop]));
}
SmtpClient objClient = new SmtpClient();
objClient.Host = "";
objClient.Send(objMessage);
MailMessage objMessage = new MailMessage();
objMessage.Bcc.Add(dicInputs["Bcc"].ToString().Trim());
objMessage.From = new MailAddress(dicInputs["From"].ToString().Trim());
objMessage.To.Add(dicInputs["To"].ToString().Trim());
objMessage.Subject = dicInputs["Subject"].ToString().Trim();
objMessage.Body = dicInputs["Message"].ToString().Trim();
string[] sAttachments = null;
sAttachments = dicInputs["Attachments"].ToString().Split(',');
for (int intLoop = 0; intLoop <= sAttachments.GetUpperBound(0); intLoop++)
{
strLogOut = strLogOut + "Adding attachment '" + sAttachments[intLoop] + "'";
objMessage.Attachments.Add(new Attachment(sAttachments[intLoop]));
}
SmtpClient objClient = new SmtpClient();
objClient.Host = "";
objClient.Send(objMessage);
Thursday, May 13, 2010
Thursday, May 6, 2010
DateDiff in Months C#
private static long monthDifference(DateTime startDate, DateTime endDate)
{
long monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}
{
long monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}
Thursday, April 29, 2010
Arraylist to String c#.net
public string toDelimitedString(string delimiter)
{
if (intAmvrrayItms > 0)
{
string[] srtArray = arrStringArray.ToArray(Type.GetType("System.String")) as string[];
return string.Join(delimiter, srtArray);
}
return null;
}
{
if (intAmvrrayItms > 0)
{
string[] srtArray = arrStringArray.ToArray(Type.GetType("System.String")) as string[];
return string.Join(delimiter, srtArray);
}
return null;
}
Monday, April 12, 2010
Precompiling Your Website
Visual Studio offers ASP.NET developers two different project types: Web Application Projects (WAP) and Web Site Projects (WSP). One of the key differences between these project types is that WAPs require explicit compilation whereas WSPs use automatic compilation, by default. With WAPs, you compile the web application's code into a single assembly, which is created in the website's
Bin
folder. Deployment entails copying the markup content (the .aspx.ascx
, and .master
Bin
folder; the code-behind class files themselves do not need to be deployed. On the other hand, you deploy WSPs by copying both the markup pages and their corresponding code-behind classes to the production environment. The code-behind classes are compiled on demand on the web server. files) in the project, along with the assembly in the Know More
Monday, March 1, 2010
Rijndael Encryption
Please see this sample code for Rijndael encryption technique:
http://www.freevbcode.com/ShowCode.Asp?ID=4520
http://www.freevbcode.com/ShowCode.Asp?ID=4520
Wednesday, February 17, 2010
SQL SERVER – How to Rename a Column Name or Table Name
Refer To this Blog:
http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/
http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/
Subscribe to:
Posts (Atom)