<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-988976672169234786</id><updated>2011-11-27T16:16:04.894-08:00</updated><category term='Recursive_Files'/><category term='Write Excel in C#'/><category term='Display data in GridView from Excel Sheet'/><category term='Sending Email'/><category term='Javascript'/><category term='Editable DatagridView linked with database'/><category term='Export to Excel with XSLT'/><category term='.Net'/><category term='Get ASCII'/><category term='DateTime + File Names'/><category term='How to Convert DataGridView into HTML Table'/><category term='FTP File Upload using FtpWebRequest in .Net C#'/><category term='Encryption'/><category term='Appling Linq on ADO.net'/><category term='GetDateFormat Method'/><category term='Render DataTable to Excel'/><category term='Mail Merge in C#'/><category term='Write CSV from DataReader'/><category term='Fragment Caching in ASP.NET'/><category term='Recursive Search for Folders and Files'/><category term='Word document C#'/><category term='Copy Folder+C#'/><category term='CheckedListBox'/><category term='Split String in C#'/><category term='How to use the radiobutton in WPF and XAML.'/><category term='ZipFile'/><category term='RowFilter'/><category term='Check password strength in javascipt'/><category term='C#.Net'/><category term='ASP.Net'/><category term='Convert Text into Title Case/Sentance Case'/><category term='System.IO'/><category term='3-Tier architecture in .Net'/><category term='WinForms'/><category term='How to write XML File from the Object Collection'/><category term='Remove Cache in ASP.net'/><category term='ADO.Net'/><category term='FTP Functions'/><title type='text'>Code snippets for .Net technology</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>67</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3355302766891235677</id><published>2011-07-22T05:19:00.001-07:00</published><updated>2011-07-22T05:19:51.159-07:00</updated><title type='text'>Comma separated values in SQL Server</title><content type='html'>For comma seperated value &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;;WITH ctm&lt;br /&gt;AS&lt;br /&gt;(&lt;br /&gt;   SELECT id,id AS idlist ,VName [Name],0 AS [Status] FROM testTableData&lt;br /&gt;   WHERE fk_id = 0&lt;br /&gt;  UNION ALL&lt;br /&gt;  SELECT ct.id,tt.id  AS idlist,tt.Vname [Name],1 AS [Status] FROM testTableData tt&lt;br /&gt;  INNER JOIN ctm AS ct ON ct.id = tt.FK_id&lt;br /&gt;  AND ct.[Status] = 0&lt;br /&gt; )&lt;br /&gt;&lt;br /&gt;SELECT * FROM ctm ORDER BY id,idlist,[Name]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3355302766891235677?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3355302766891235677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/07/comma-separated-values-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3355302766891235677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3355302766891235677'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/07/comma-separated-values-in-sql-server.html' title='Comma separated values in SQL Server'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2739088085141963220</id><published>2011-06-22T03:55:00.000-07:00</published><updated>2011-06-22T03:55:56.104-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mail Merge in C#'/><title type='text'>Automate mail merge in C#</title><content type='html'>private void MailMerge()&lt;br /&gt;        {&lt;br /&gt;            # region local variables&lt;br /&gt;&lt;br /&gt;            Object oMissing = System.Reflection.Missing.Value;&lt;br /&gt;&lt;br /&gt;            Object oTrue = true;&lt;br /&gt;            Object oFalse = false;&lt;br /&gt;&lt;br /&gt;            Word.Application oWord = new Word.Application();&lt;br /&gt;            Word.Document oWordDoc = new Word.Document();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            oWord.Visible = true;&lt;br /&gt;&lt;br /&gt;            // Word Mail Merge Template file&lt;br /&gt;            Object oTemplatePath = System.Windows.Forms.Application.StartupPath+ "\\Report.dot";&lt;br /&gt;&lt;br /&gt;            oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);&lt;br /&gt;&lt;br /&gt;            #endregion&lt;br /&gt;&lt;br /&gt;            foreach (Word.Field myMergeField in oWordDoc.Fields)&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                iTotalFields++;&lt;br /&gt;                Word.Range rngFieldCode = myMergeField.Code;&lt;br /&gt;                String fieldText = rngFieldCode.Text;&lt;br /&gt;&lt;br /&gt;                if (fieldText.StartsWith(" MERGEFIELD"))&lt;br /&gt;                {&lt;br /&gt;                    // example: MERGEFIELD  Name  \* MERGEFORMAT &lt;br /&gt;                    Int32 endMerge = fieldText.IndexOf("\\");&lt;br /&gt;                    Int32 fieldNameLength = fieldText.Length - endMerge;&lt;br /&gt;                    String fieldName = fieldText.Substring(11, endMerge - 11); // [Name]&lt;br /&gt;&lt;br /&gt;                    fieldName = fieldName.Trim();&lt;br /&gt;&lt;br /&gt;                    if (fieldName == "Name")&lt;br /&gt;                    {&lt;br /&gt;                        myMergeField.Select();&lt;br /&gt;                        oWord.Selection.TypeText(txt_name.Text);&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if (fieldName == "Address")&lt;br /&gt;                    {&lt;br /&gt;                        myMergeField.Select();&lt;br /&gt;                        oWord.Selection.TypeText(txt_address.Text);&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if (fieldName == "Age")&lt;br /&gt;                    {&lt;br /&gt;                        myMergeField.Select();&lt;br /&gt;                        oWord.Selection.TypeText(num_age.Text);&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if (fieldName == "EAddress")&lt;br /&gt;                    {&lt;br /&gt;                        myMergeField.Select();&lt;br /&gt;                        oWord.Selection.TypeText(txt_email.Text);&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if (fieldName == "Company")&lt;br /&gt;                    {&lt;br /&gt;                        myMergeField.Select();&lt;br /&gt;                        oWord.Selection.TypeText(txt_company.Text);&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if (fieldName == "TelNo")&lt;br /&gt;                    {&lt;br /&gt;                        myMergeField.Select();&lt;br /&gt;                        oWord.Selection.TypeText(txt_tel.Text);&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if (fieldName == "ODetails")&lt;br /&gt;                    {&lt;br /&gt;                        myMergeField.Select();&lt;br /&gt;                        oWord.Selection.TypeText(txt_odetails.Text);&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Open File&lt;br /&gt;           &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;Structure of the template document&lt;br /&gt;&lt;br /&gt;Name: «Name»&lt;br /&gt;Address: «Address»&lt;br /&gt;Age: «Age»&lt;br /&gt;E-mail Address: «EAddress»&lt;br /&gt;Company: «Company»&lt;br /&gt;Telephone Number: «TelNo»&lt;br /&gt;Other Details: «ODetails»&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2739088085141963220?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2739088085141963220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/06/automate-mail-merge-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2739088085141963220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2739088085141963220'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/06/automate-mail-merge-in-c.html' title='Automate mail merge in C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-340887754963827186</id><published>2011-04-01T05:46:00.000-07:00</published><updated>2011-04-01T05:47:04.166-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Recursive Search for Folders and Files'/><title type='text'>Recursive Search for Folders and Files</title><content type='html'>public ClsFolderNFileCollection GetCollectionOfRecursiveDirAndFiles(string Src, List&lt;string&gt; Elements)&lt;br /&gt;{&lt;br /&gt;ClsFolderNFileCollection objDirAndFileCollection = new ClsFolderNFileCollection();&lt;br /&gt;string[] Files;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;Files = Directory.GetFileSystemEntries(Src);&lt;br /&gt;foreach (string Element in Files)&lt;br /&gt;{&lt;br /&gt;// Sub directories&lt;br /&gt;&lt;br /&gt;if (Directory.Exists(Element))&lt;br /&gt;{&lt;br /&gt;objDirAndFileCollection.FolderCollection.Add(Element);&lt;br /&gt;GetCollectionOfRecursiveDirAndFiles(Element, Elements);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;objDirAndFileCollection.FileCollection.Add(Element);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;throw new Exception(ex.Message);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return objDirAndFileCollection;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//  Return Class&lt;br /&gt;&lt;br /&gt;public class ClsFolderNFileCollection&lt;br /&gt;{&lt;br /&gt;public  List&lt;string&gt; FileCollection { get; set; }&lt;br /&gt;public  List&lt;string&gt; FolderCollection { get; set; }&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-340887754963827186?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/340887754963827186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/04/recursive-search-for-folders-and-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/340887754963827186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/340887754963827186'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/04/recursive-search-for-folders-and-files.html' title='Recursive Search for Folders and Files'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-4260416009957981102</id><published>2011-03-28T05:00:00.000-07:00</published><updated>2011-03-28T05:00:01.384-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DateTime + File Names'/><title type='text'>DateTime Stamp Functions</title><content type='html'>public static string DateTimeIn24Hours()&lt;br /&gt;        {&lt;br /&gt;            return DateTime.Now.ToString("yyyyMMddHHmm");&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        public static string DateTimeWithUniqueID()&lt;br /&gt;        {&lt;br /&gt;            string guid = Guid.NewGuid().ToString();&lt;br /&gt;&lt;br /&gt;            return DateTime.Now.ToString("yyyymmdd") + guid;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-4260416009957981102?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/4260416009957981102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/datetime-stamp-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4260416009957981102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4260416009957981102'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/datetime-stamp-functions.html' title='DateTime Stamp Functions'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2976693247960459525</id><published>2011-03-22T05:37:00.001-07:00</published><updated>2011-03-23T01:16:19.560-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='FTP Functions'/><title type='text'>General Class for FTP Functions</title><content type='html'>class FTPFunctions&lt;br /&gt;{&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// To Make Directory on the FTP-Server&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="dirName"&gt;&lt;/param&gt;public static void MakeDir(string dirName)&lt;br /&gt;{&lt;br /&gt;FtpWebRequest reqFTP = null;&lt;br /&gt;Stream ftpStream = null;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + dirName));&lt;br /&gt;&lt;br /&gt;reqFTP.Method = WebRequestMethods.Ftp.MakeDirectory;&lt;br /&gt;reqFTP.UseBinary = true;&lt;br /&gt;reqFTP.Credentials = new NetworkCredential(FTPSettings.UserID, FTPSettings.Password);&lt;br /&gt;FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();&lt;br /&gt;ftpStream = response.GetResponseStream();&lt;br /&gt;ftpStream.Close();&lt;br /&gt;response.Close();&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;if (ftpStream != null)&lt;br /&gt;{&lt;br /&gt;ftpStream.Close();&lt;br /&gt;ftpStream.Dispose();&lt;br /&gt;}&lt;br /&gt;throw new Exception(ex.Message.ToString());&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// To Check Whether Folder exists or not on the FTP-Server&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="OurDir"&gt;&lt;/param&gt;/// &lt;param name="FTPDir"&gt;&lt;/param&gt;/// &lt;param name="FTPUser"&gt;&lt;/param&gt;/// &lt;param name="FTPPassword"&gt;&lt;/param&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static bool FtpDirectoryExists(string OurDir, string FTPDir, string FTPUser, string FTPPassword)&lt;br /&gt;{&lt;br /&gt;bool IsExists = true;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;FtpWebRequest request;&lt;br /&gt;&lt;br /&gt;// Create FtpWebRequest object from the Uri provided&lt;br /&gt;if (!FTPDir.Contains("ftp://"))&lt;br /&gt;{&lt;br /&gt;request = (FtpWebRequest)FtpWebRequest.Create&lt;br /&gt;(new Uri("ftp://" + FTPDir));&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;request = (FtpWebRequest)FtpWebRequest.Create&lt;br /&gt;(new Uri(FTPDir));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// request = (FtpWebRequest)WebRequest.Create(FTPDir);&lt;br /&gt;request.Credentials = new NetworkCredential(FTPUser, FTPPassword);&lt;br /&gt;request.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;&lt;br /&gt;&lt;br /&gt;FtpWebResponse response = (FtpWebResponse)request.GetResponse();&lt;br /&gt;}&lt;br /&gt;catch (WebException ex)&lt;br /&gt;{&lt;br /&gt;IsExists = false;&lt;br /&gt;}&lt;br /&gt;return IsExists;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Upload file on the FTP-Server&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="inputfilepath"&gt;&lt;/param&gt;/// &lt;param name="ftpfilepath"&gt;&lt;/param&gt;/// &lt;param name="strFTPUser"&gt;&lt;/param&gt;/// &lt;param name="strFTPPwd"&gt;&lt;/param&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static bool ftpfile(string inputfilepath, string ftpfilepath, string strFTPUser, string strFTPPwd)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;FileInfo fileInf = new FileInfo(inputfilepath);&lt;br /&gt;&lt;br /&gt;FtpWebRequest ftp;&lt;br /&gt;&lt;br /&gt;// Create FtpWebRequest object from the Uri provided&lt;br /&gt;if (!ftpfilepath.Contains("ftp://"))&lt;br /&gt;{&lt;br /&gt;ftp = (FtpWebRequest)FtpWebRequest.Create&lt;br /&gt;(new Uri("ftp://" + ftpfilepath + "/" + fileInf.Name));&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;ftp = (FtpWebRequest)FtpWebRequest.Create&lt;br /&gt;(new Uri(ftpfilepath + "/" + fileInf.Name));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;ftp.Credentials = new NetworkCredential(strFTPUser, strFTPPwd);&lt;br /&gt;&lt;br /&gt;ftp.KeepAlive = true;&lt;br /&gt;ftp.UseBinary = true;&lt;br /&gt;ftp.Method = WebRequestMethods.Ftp.UploadFile;&lt;br /&gt;FileStream fs = File.OpenRead(inputfilepath);&lt;br /&gt;byte[] buffer = new byte[fs.Length];&lt;br /&gt;fs.Read(buffer, 0, buffer.Length);&lt;br /&gt;fs.Close();&lt;br /&gt;Stream ftpstream = ftp.GetRequestStream();&lt;br /&gt;ftpstream.Write(buffer, 0, buffer.Length);&lt;br /&gt;ftpstream.Close();&lt;br /&gt;&lt;br /&gt;return true;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;// WriteLog("Unable to upload zip file: '"+strFilename+"' - Excep: " + ex.Message);&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Get MetaData of the FTP-File&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="ftpServerIP"&gt;&lt;/param&gt;/// &lt;param name="ftpUserID"&gt;&lt;/param&gt;/// &lt;param name="ftpPassword"&gt;&lt;/param&gt;/// &lt;param name="strFolderName"&gt;&lt;/param&gt;/// &lt;param name="strFileName"&gt;&lt;/param&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static FTPFileMetaData GetMetaDataFTPFile(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName, string strFileName)&lt;br /&gt;{&lt;br /&gt;FTPFileMetaData metaData = new FTPFileMetaData();&lt;br /&gt;FtpWebRequest reqFTP;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;long fileSize = 0;&lt;br /&gt;&lt;br /&gt;if (!ftpServerIP.Contains("ftp://"))&lt;br /&gt;{&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" +&lt;br /&gt;ftpServerIP + "/" + strFolderName + "/" + strFileName));&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP +&lt;br /&gt;"/" + strFolderName + "/" + strFileName));&lt;br /&gt;}&lt;br /&gt;reqFTP.Method = WebRequestMethods.Ftp.GetDateTimestamp;&lt;br /&gt;reqFTP.UseBinary = true;&lt;br /&gt;reqFTP.KeepAlive = false;&lt;br /&gt;reqFTP.Credentials = new NetworkCredential(ftpUserID,&lt;br /&gt;ftpPassword);&lt;br /&gt;FtpWebResponse response;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;response = (FtpWebResponse)reqFTP.GetResponse();&lt;br /&gt;&lt;br /&gt;DateTime lastModified = response.LastModified;&lt;br /&gt;&lt;br /&gt;metaData.FileName = strFileName;&lt;br /&gt;metaData.ModifiedTime = lastModified;&lt;br /&gt;Stream ftpStream = response.GetResponseStream();&lt;br /&gt;fileSize = response.ContentLength;&lt;br /&gt;metaData.FileLength = fileSize;&lt;br /&gt;metaData.FileLength = GetFTPFileSize(ftpServerIP, ftpUserID, ftpPassword, strFolderName, strFileName);&lt;br /&gt;&lt;br /&gt;return metaData;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;// BLayer.WriteLog("Error in FTPModule for MetaData " + ex.ToString() + "-" + DateTime.Now);&lt;br /&gt;return metaData;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Delete file from the FTP-Server&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="ftpServerIP"&gt;&lt;/param&gt;/// &lt;param name="ftpUserID"&gt;&lt;/param&gt;/// &lt;param name="ftpPassword"&gt;&lt;/param&gt;/// &lt;param name="strFolderName"&gt;&lt;/param&gt;/// &lt;param name="strFileName"&gt;&lt;/param&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static bool DeleteFileFromFTPServer(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName, string strFileName)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;FtpWebRequest request;&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;if (!ftpServerIP.Contains("ftp://"))&lt;br /&gt;{&lt;br /&gt;request = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" +&lt;br /&gt;ftpServerIP + "/" + strFolderName + "/" + strFileName));&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP +&lt;br /&gt;"/" + strFolderName + "/" + strFileName));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;request.Credentials = new NetworkCredential(ftpUserID,&lt;br /&gt;ftpPassword);&lt;br /&gt;request.Method = WebRequestMethods.Ftp.DeleteFile;&lt;br /&gt;&lt;br /&gt;FtpWebResponse response = (FtpWebResponse)request.GetResponse();&lt;br /&gt;&lt;br /&gt;response.Close();&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Get File-Size&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="ftpServerIP"&gt;&lt;/param&gt;/// &lt;param name="ftpUserID"&gt;&lt;/param&gt;/// &lt;param name="ftpPassword"&gt;&lt;/param&gt;/// &lt;param name="strFolderName"&gt;&lt;/param&gt;/// &lt;param name="strFileName"&gt;&lt;/param&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static long GetFTPFileSize(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName, string strFileName)&lt;br /&gt;{&lt;br /&gt;FtpWebRequest reqFTP;&lt;br /&gt;long fileSize = 0;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + strFolderName + "/" + strFileName));&lt;br /&gt;reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;&lt;br /&gt;reqFTP.UseBinary = true;&lt;br /&gt;reqFTP.KeepAlive = false;&lt;br /&gt;reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);&lt;br /&gt;FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();&lt;br /&gt;Stream ftpStream = response.GetResponseStream();&lt;br /&gt;fileSize = response.ContentLength;&lt;br /&gt;&lt;br /&gt;ftpStream.Close();&lt;br /&gt;response.Close();&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;// BLayer.WriteLog("Error in FTPModule for FileSize " + ex.ToString() + "-" + DateTime.Now);&lt;br /&gt;}&lt;br /&gt;return fileSize;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Download file from the FTP-Server&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="ftpServerIP"&gt;&lt;/param&gt;/// &lt;param name="ftpUserID"&gt;&lt;/param&gt;/// &lt;param name="ftpPassword"&gt;&lt;/param&gt;/// &lt;param name="strFolderName"&gt;&lt;/param&gt;/// &lt;param name="strFileName"&gt;&lt;/param&gt;/// &lt;param name="DestFolder"&gt;&lt;/param&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;public static bool DownloadFileFromFTPServer(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName, string strFileName, string DestFolder)&lt;br /&gt;{&lt;br /&gt;FtpWebRequest reqFTP;&lt;br /&gt;&lt;br /&gt;if (!ftpServerIP.Contains("ftp://"))&lt;br /&gt;{&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" +&lt;br /&gt;ftpServerIP + "/" + strFolderName + "/" + strFileName));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP +&lt;br /&gt;"/" + strFolderName + "/" + strFileName));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;&lt;br /&gt;reqFTP.UseBinary = true;&lt;br /&gt;reqFTP.KeepAlive = false;&lt;br /&gt;reqFTP.Credentials = new NetworkCredential(ftpUserID,&lt;br /&gt;ftpPassword);&lt;br /&gt;FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();&lt;br /&gt;Stream ftpStream = response.GetResponseStream();&lt;br /&gt;long cl = response.ContentLength;&lt;br /&gt;int bufferSize = 2048;&lt;br /&gt;int readCount;&lt;br /&gt;byte[] buffer = new byte[bufferSize];&lt;br /&gt;&lt;br /&gt;readCount = ftpStream.Read(buffer, 0, bufferSize);&lt;br /&gt;Directory.CreateDirectory(DestFolder);&lt;br /&gt;&lt;br /&gt;FileStream outputStream = new FileStream(DestFolder +&lt;br /&gt;Path.DirectorySeparatorChar + strFileName, FileMode.Create);&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;while (readCount &gt; 0)&lt;br /&gt;{&lt;br /&gt;outputStream.Write(buffer, 0, readCount);&lt;br /&gt;readCount = ftpStream.Read(buffer, 0, bufferSize);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;ftpStream.Close();&lt;br /&gt;outputStream.Close();&lt;br /&gt;response.Close();&lt;br /&gt;&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;string errMsg = "There is problem in downloading file from: " + DestFolder + "\\" + strFileName;&lt;br /&gt;errMsg = errMsg + ": " + ex.Message.ToString();&lt;br /&gt;&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// Get File-listing from the FTP-Server&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="ftpServerIP"&gt;&lt;/param&gt;/// &lt;param name="ftpUserID"&gt;&lt;/param&gt;/// &lt;param name="ftpPassword"&gt;&lt;/param&gt;/// &lt;param name="strFolderName"&gt;&lt;/param&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;public static List&lt;string&gt; GetFTPFileList(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName)&lt;br /&gt;{&lt;br /&gt;string[] downloadFiles;&lt;br /&gt;StringBuilder result = new StringBuilder();&lt;br /&gt;FtpWebRequest reqFTP;&lt;br /&gt;List&lt;string&gt; FTPFiles = new List&lt;string&gt;();&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;if (!ftpServerIP.Contains("ftp://"))&lt;br /&gt;{&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" +&lt;br /&gt;ftpServerIP + "/" + strFolderName));&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP +&lt;br /&gt;"/" + strFolderName));&lt;br /&gt;}&lt;br /&gt;reqFTP.UseBinary = true;&lt;br /&gt;reqFTP.KeepAlive = false;&lt;br /&gt;reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);&lt;br /&gt;reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;&lt;br /&gt;WebResponse response = reqFTP.GetResponse();&lt;br /&gt;StreamReader reader = new StreamReader(response.GetResponseStream());&lt;br /&gt;//MessageBox.Show(reader.ReadToEnd());&lt;br /&gt;string line = reader.ReadLine();&lt;br /&gt;while (line != null)&lt;br /&gt;{&lt;br /&gt;result.Append(line);&lt;br /&gt;result.Append("\n");&lt;br /&gt;line = reader.ReadLine();&lt;br /&gt;}&lt;br /&gt;result.Remove(result.ToString().LastIndexOf('\n'), 1);&lt;br /&gt;reader.Close();&lt;br /&gt;response.Close();&lt;br /&gt;//MessageBox.Show(response.StatusDescription);&lt;br /&gt;downloadFiles = result.ToString().Split('\n');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;foreach (string s in downloadFiles)&lt;br /&gt;{&lt;br /&gt;FTPFileMetaData data = GetMetaDataFTPFile(ftpServerIP, ftpUserID, ftpPassword, strFolderName, s);&lt;br /&gt;&lt;br /&gt;// Here we requires only file name&lt;br /&gt;&lt;br /&gt;FTPFiles.Add(data.FileName);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return FTPFiles;&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;return FTPFiles;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;  /// &lt;summary&gt;&lt;br /&gt;        /// Get Folder List from the FTP-Server&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="ftpServerIP"&gt;&lt;/param&gt;        /// &lt;param name="ftpUserID"&gt;&lt;/param&gt;        /// &lt;param name="ftpPassword"&gt;&lt;/param&gt;        /// &lt;param name="strFolderName"&gt;&lt;/param&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public static List&lt;string&gt; GetDirectoryListingFromFTPServer(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            FtpWebRequest request;&lt;br /&gt;&lt;br /&gt;            StringBuilder result = new StringBuilder();&lt;br /&gt;            List&lt;string&gt; directories = new List&lt;string&gt;();&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;            &lt;br /&gt;            if (!ftpServerIP.Contains("ftp://"))&lt;br /&gt;            {&lt;br /&gt;                request = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" +&lt;br /&gt;                                        ftpServerIP + "/" + strFolderName));&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP +&lt;br /&gt;                                         "/" + strFolderName));&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            &lt;br /&gt;            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;&lt;br /&gt;            request.Credentials = new NetworkCredential(ftpUserID,&lt;br /&gt;                ftpPassword);&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;                FtpWebResponse response = (FtpWebResponse)&lt;br /&gt;                    request.GetResponse();&lt;br /&gt;&lt;br /&gt;                Stream responseStream = response.GetResponseStream();&lt;br /&gt;                StreamReader reader = new StreamReader(responseStream);&lt;br /&gt;                string line = reader.ReadLine();&lt;br /&gt;                while (line != null)&lt;br /&gt;                {&lt;br /&gt;                    //  Filtering folder names from the ListingString &lt;br /&gt;                    if (line.StartsWith("drw-") &amp;&amp; !(line.EndsWith(".")))&lt;br /&gt;                    {&lt;br /&gt;                        if (line.Contains(":"))&lt;br /&gt;                        {&lt;br /&gt;                            result.Append(line.Substring(line.LastIndexOf(":") + 4));&lt;br /&gt;                            result.Append("\n");&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                    line = reader.ReadLine();&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                directories.AddRange(result.ToString().Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                reader.Close();&lt;br /&gt;                response.Close();&lt;br /&gt;&lt;br /&gt;                return directories;&lt;br /&gt;            }&lt;br /&gt;            catch (WebException e)&lt;br /&gt;            {&lt;br /&gt;                return directories;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Check Existence of the File on FTP-Server&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="fullFtpFilepath"&gt;&lt;/param&gt;        /// &lt;param name="userName"&gt;&lt;/param&gt;        /// &lt;param name="passWord"&gt;&lt;/param&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public bool IsFileExistsFTPServerURI(string fullFtpFilepath, string userName,string passWord)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            bool exists = true;&lt;br /&gt;&lt;br /&gt;            var request =&lt;br /&gt;&lt;br /&gt;            (FtpWebRequest)WebRequest.Create(fullFtpFilepath);&lt;br /&gt;&lt;br /&gt;            request.Credentials =&lt;br /&gt;&lt;br /&gt;            new NetworkCredential(userName, passWord);&lt;br /&gt;&lt;br /&gt;            request.Method =&lt;br /&gt;&lt;br /&gt;            WebRequestMethods.Ftp.GetDateTimestamp;&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                FtpWebResponse response =&lt;br /&gt;&lt;br /&gt;                (FtpWebResponse)request.GetResponse();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch (WebException ex)&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                FtpWebResponse response = (FtpWebResponse)ex.Response;&lt;br /&gt;&lt;br /&gt;                if (response.StatusCode ==&lt;br /&gt;&lt;br /&gt;                FtpStatusCode.ActionNotTakenFileUnavailable)&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                    exists = false; //File does not exist&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return exists;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2976693247960459525?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2976693247960459525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/general-class-for-ftp-functions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2976693247960459525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2976693247960459525'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/general-class-for-ftp-functions.html' title='General Class for FTP Functions'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-7338040154089890194</id><published>2011-03-04T04:49:00.000-08:00</published><updated>2011-03-04T04:51:30.773-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Export to Excel with XSLT'/><title type='text'>Data Table Export to Excel with XSLT</title><content type='html'>Util Class:&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Xml;&lt;br /&gt;using System.Threading;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Xml.Xsl;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Xml.XPath;&lt;br /&gt;&lt;br /&gt;namespace Auditor_Apps&lt;br /&gt;{&lt;br /&gt;    class DataSetToExcelUtil&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private string appType;&lt;br /&gt;        private HttpResponse response;&lt;br /&gt;&lt;br /&gt;        private void CreateStylesheet(XmlTextWriter writer, string[] sHeaders, string[] sFileds, ExportFormat FormatType)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                string ns = "http://www.w3.org/1999/XSL/Transform";&lt;br /&gt;                writer.Formatting = Formatting.Indented;&lt;br /&gt;                writer.WriteStartDocument();&lt;br /&gt;                writer.WriteStartElement("xsl", "stylesheet", ns);&lt;br /&gt;                writer.WriteAttributeString("version", "1.0");&lt;br /&gt;                writer.WriteStartElement("xsl:output");&lt;br /&gt;                writer.WriteAttributeString("method", "text");&lt;br /&gt;                writer.WriteAttributeString("version", "4.0");&lt;br /&gt;                writer.WriteEndElement();&lt;br /&gt;                writer.WriteStartElement("xsl:template");&lt;br /&gt;                writer.WriteAttributeString("match", "/");&lt;br /&gt;                for (int i = 0; i &lt; sHeaders.Length; i++)                {                    writer.WriteString("\"");                    writer.WriteStartElement("xsl:value-of");                    writer.WriteAttributeString("select", "'" + sHeaders[i] + "'");                    writer.WriteEndElement();                    writer.WriteString("\"");                    if (i != (sFileds.Length - 1))                    {                        writer.WriteString((FormatType == ExportFormat.CSV) ? "," : "\t");                    }                }                writer.WriteStartElement("xsl:for-each");                writer.WriteAttributeString("select", "Export/Values");                writer.WriteString("\r\n");                for (int j = 0; j &lt; sFileds.Length; j++)                {                    writer.WriteString("\"");                    writer.WriteStartElement("xsl:value-of");                    writer.WriteAttributeString("select", sFileds[j]);                    writer.WriteEndElement();                    writer.WriteString("\"");                    if (j != (sFileds.Length - 1))                    {                        writer.WriteString((FormatType == ExportFormat.CSV) ? "," : "\t");                    }                }                writer.WriteEndElement();                writer.WriteEndElement();                writer.WriteEndElement();                writer.WriteEndDocument();            }            catch (Exception exception)            {                throw exception;            }        }        public enum ExportFormat        {            CSV = 1,            Excel = 2        }        public enum AppType        {            WEB = 1,            Winform = 2        }        public void ExportDetails(DataTable DetailsTable, ExportFormat FormatType, AppType appType, string FileName)        {            try            {                if (DetailsTable.Rows.Count == 0)                {                    throw new Exception("There are no details to export.");                }                DataSet dsExport = new DataSet("Export");                DataTable table = DetailsTable.Copy();                table.TableName = "Values";                dsExport.Tables.Add(table);                string[] sHeaders = new string[table.Columns.Count];                string[] sFileds = new string[table.Columns.Count];                for (int i = 0; i &lt; table.Columns.Count; i++)                {                    sHeaders[i] = table.Columns[i].ColumnName;                    sFileds[i] = this.ReplaceSpclChars(table.Columns[i].ColumnName);                }                if (appType == AppType.WEB)                {                    this.Export_with_XSLT_Web(dsExport, sHeaders, sFileds, FormatType, FileName);                }                else if (appType == AppType.Winform)                {                    this.Export_with_XSLT_Windows(dsExport, sHeaders, sFileds, FormatType, FileName);                }            }            catch (Exception exception)            {                throw exception;            }        }        private void Export_with_XSLT_Web(DataSet dsExport, string[] sHeaders, string[] sFileds, ExportFormat FormatType, string FileName)        {            try            {                this.response.Clear();                this.response.Buffer = true;                if (FormatType == ExportFormat.CSV)                {                    this.response.ContentType = "text/csv";                    this.response.AppendHeader("content-disposition", "attachment; filename=" + FileName);                }                else                {                    this.response.ContentType = "application/vnd.ms-excel";                    this.response.AppendHeader("content-disposition", "attachment; filename=" + FileName);                }                MemoryStream w = new MemoryStream();                XmlTextWriter writer = new XmlTextWriter(w, Encoding.UTF8);                this.CreateStylesheet(writer, sHeaders, sFileds, FormatType);                writer.Flush();                w.Seek(0L, SeekOrigin.Begin);                XmlDataDocument document = new XmlDataDocument(dsExport);                XslTransform transform = new XslTransform();                transform.Load(new XmlTextReader(w), null, null);                StringWriter writer2 = new StringWriter();                transform.Transform((IXPathNavigable)document, null, (TextWriter)writer2, null);                this.response.Write(writer2.ToString());                writer2.Close();                writer.Close();                w.Close();                this.response.End();            }            catch (ThreadAbortException exception)            {                string message = exception.Message;            }            catch (Exception exception2)            {                throw exception2;            }        }        public void ExportDetails(DataTable DetailsTable, int[] ColumnList, ExportFormat FormatType, AppType appType, string FileName)        {            try            {                if (DetailsTable.Rows.Count == 0)                {                    throw new Exception("There are no details to export");                }                DataSet dsExport = new DataSet("Export");                DataTable table = DetailsTable.Copy();                table.TableName = "Values";                dsExport.Tables.Add(table);                if (ColumnList.Length &gt; table.Columns.Count)&lt;br /&gt;                {&lt;br /&gt;                    throw new Exception("ExportColumn List should not exceed Total Columns");&lt;br /&gt;                }&lt;br /&gt;                string[] sHeaders = new string[ColumnList.Length];&lt;br /&gt;                string[] sFileds = new string[ColumnList.Length];&lt;br /&gt;                for (int i = 0; i &lt; ColumnList.Length; i++)                {                    if ((ColumnList[i] &lt; 0) || (ColumnList[i] &gt;= table.Columns.Count))&lt;br /&gt;                    {&lt;br /&gt;                        throw new Exception("ExportColumn Number should not exceed Total Columns Range");&lt;br /&gt;                    }&lt;br /&gt;                    sHeaders[i] = table.Columns[ColumnList[i]].ColumnName;&lt;br /&gt;                    sFileds[i] = this.ReplaceSpclChars(table.Columns[ColumnList[i]].ColumnName);&lt;br /&gt;                }&lt;br /&gt;                if (appType == AppType.WEB)&lt;br /&gt;                {&lt;br /&gt;                    this.Export_with_XSLT_Web(dsExport, sHeaders, sFileds, FormatType, FileName);&lt;br /&gt;                }&lt;br /&gt;                else if (appType == AppType.Winform)&lt;br /&gt;                {&lt;br /&gt;                    this.Export_with_XSLT_Windows(dsExport, sHeaders, sFileds, FormatType, FileName);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            catch (Exception exception)&lt;br /&gt;            {&lt;br /&gt;                throw exception;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        private void Export_with_XSLT_Windows(DataSet dsExport, string[] sHeaders, string[] sFileds, ExportFormat FormatType, string FileName)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                MemoryStream w = new MemoryStream();&lt;br /&gt;                XmlTextWriter writer = new XmlTextWriter(w, Encoding.UTF8);&lt;br /&gt;                this.CreateStylesheet(writer, sHeaders, sFileds, FormatType);&lt;br /&gt;                writer.Flush();&lt;br /&gt;                w.Seek(0L, SeekOrigin.Begin);&lt;br /&gt;                XmlDataDocument document = new XmlDataDocument(dsExport);&lt;br /&gt;                XslTransform transform = new XslTransform();&lt;br /&gt;                transform.Load(new XmlTextReader(w), null, null);&lt;br /&gt;                StringWriter writer2 = new StringWriter();&lt;br /&gt;                transform.Transform((IXPathNavigable)document, null, (TextWriter)writer2, null);&lt;br /&gt;                StreamWriter writer3 = new StreamWriter(FileName);&lt;br /&gt;                writer3.WriteLine(writer2.ToString());&lt;br /&gt;                writer3.Close();&lt;br /&gt;                writer2.Close();&lt;br /&gt;                writer.Close();&lt;br /&gt;                w.Close();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception exception)&lt;br /&gt;            {&lt;br /&gt;                throw exception;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private string ReplaceSpclChars(string fieldName)&lt;br /&gt;        {&lt;br /&gt;            fieldName = fieldName.Replace(" ", "_x0020_");&lt;br /&gt;            fieldName = fieldName.Replace("%", "_x0025_");&lt;br /&gt;            fieldName = fieldName.Replace("#", "_x0023_");&lt;br /&gt;            fieldName = fieldName.Replace("&amp;", "_x0026_");&lt;br /&gt;            fieldName = fieldName.Replace("/", "_x002F_");&lt;br /&gt;            return fieldName;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Implementation code:&lt;br /&gt;&lt;br /&gt;DataSetToExcelUtil ObjUtil = new DataSetToExcelUtil();&lt;br /&gt;&lt;br /&gt;ObjUtil.ExportDetails(dt, DataSetToExcelUtil.ExportFormat.Excel, DataSetToExcelUtil.AppType.Winform, ExcelPath);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-7338040154089890194?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/7338040154089890194/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/data-table-export-to-excel-with-xslt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7338040154089890194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7338040154089890194'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/data-table-export-to-excel-with-xslt.html' title='Data Table Export to Excel with XSLT'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8506820969573426721</id><published>2011-03-03T02:48:00.001-08:00</published><updated>2011-03-03T02:48:34.676-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Get ASCII'/><title type='text'>Get ASCII in C#</title><content type='html'>public static string GetASCIIValue(string strValue)&lt;br /&gt;        {&lt;br /&gt;            return Encoding.ASCII.GetString(&lt;br /&gt;            Encoding.Convert(&lt;br /&gt;                Encoding.UTF8,&lt;br /&gt;                Encoding.GetEncoding(&lt;br /&gt;                    Encoding.ASCII.EncodingName,&lt;br /&gt;                    new EncoderReplacementFallback(string.Empty),&lt;br /&gt;                    new DecoderExceptionFallback()&lt;br /&gt;                    ),&lt;br /&gt;                Encoding.UTF8.GetBytes(strValue)&lt;br /&gt;            )&lt;br /&gt;        );&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;string s1 = FinancialMIS_Apps.StringManipulation.GetASCIIValue("Expression");&lt;br /&gt;string s2 = FinancialMIS_Apps.StringManipulation.GetASCIIValue("Räksmörgås");&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8506820969573426721?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8506820969573426721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/get-ascii-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8506820969573426721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8506820969573426721'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/03/get-ascii-in-c.html' title='Get ASCII in C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-688295860327666973</id><published>2011-02-07T01:04:00.000-08:00</published><updated>2011-02-07T01:04:14.500-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Write Excel in C#'/><title type='text'>How to write custom formatted excel in C# from dataTable</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Drawing;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using Export_Excel = RKLib.ExportData;&lt;br /&gt;using System.IO;&lt;br /&gt;using MyExcel = Microsoft.Office.Interop.Excel;&lt;br /&gt;&lt;br /&gt;public class FormattedMISReports &lt;br /&gt;    {&lt;br /&gt;        public static string ExportDataTableToExcel(DataTable dtSource, string ExcelPath, bool blnFirstSheet, string sheetName, int sheetIndex)&lt;br /&gt;        {&lt;br /&gt;            MyExcel.Application oXL;&lt;br /&gt;            MyExcel.Workbook oWB;&lt;br /&gt;            MyExcel.Worksheet oSheet;&lt;br /&gt;            MyExcel.Range oRange;&lt;br /&gt;            &lt;br /&gt;            List&lt;int&gt; CustomIndex = new List&lt;int&gt;();&lt;br /&gt;            CustomIndex.Add(14);&lt;br /&gt;            CustomIndex.Add(40);&lt;br /&gt;            CustomIndex.Add(41);&lt;br /&gt;            CustomIndex.Add(88);&lt;br /&gt;            CustomIndex.Add(89);&lt;br /&gt;            CustomIndex.Add(90);&lt;br /&gt;            CustomIndex.Add(91);&lt;br /&gt;            CustomIndex.Add(96);&lt;br /&gt;&lt;br /&gt;            List&lt;int&gt; NonHypen = new List&lt;int&gt;();&lt;br /&gt;            NonHypen.Add(92);&lt;br /&gt;            NonHypen.Add(93);&lt;br /&gt;            NonHypen.Add(94);&lt;br /&gt;            NonHypen.Add(95);&lt;br /&gt;       &lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                // Start Excel and get Application object.&lt;br /&gt;                oXL = new MyExcel.Application();&lt;br /&gt;&lt;br /&gt;                // Set some properties&lt;br /&gt;                oXL.DisplayAlerts = false;&lt;br /&gt;                oXL.Visible = true;&lt;br /&gt;&lt;br /&gt;                if (blnFirstSheet)&lt;br /&gt;                {&lt;br /&gt;                    // Get a new workbook.&lt;br /&gt;                    oWB = oXL.Workbooks.Add(Type.Missing);&lt;br /&gt;&lt;br /&gt;                    // Adding extra sheets in the workbook&lt;br /&gt;                    oWB.Sheets.Add(Type.Missing, oWB.Worksheets[oWB.Worksheets.Count], 7, Microsoft.Office.Interop.Excel.XlSheetType.xlWorksheet);&lt;br /&gt;&lt;br /&gt;                    // Activating first sheet in the workbook&lt;br /&gt;                    oSheet = (MyExcel.Worksheet)oWB.Worksheets[sheetIndex];&lt;br /&gt;&lt;br /&gt;                    oSheet.Activate();&lt;br /&gt;&lt;br /&gt;                    oSheet.Name = sheetName;&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    // opening existing excel file&lt;br /&gt;                    oWB = oXL.Workbooks.Open(ExcelPath, 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", false, false, 0, true, 0, 0);&lt;br /&gt;&lt;br /&gt;                    // Activating first sheet in the workbook&lt;br /&gt;                    oSheet = (MyExcel.Worksheet)oWB.Worksheets[sheetIndex];&lt;br /&gt;&lt;br /&gt;                    oSheet.Activate();&lt;br /&gt;&lt;br /&gt;                    oSheet.Name = sheetName;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                &lt;br /&gt;&lt;br /&gt;                // Header Text&lt;br /&gt;                oSheet.Cells[1, 1] = "IDS Infotech Ltd.";&lt;br /&gt;                oSheet.Cells[2, 1] = "Department: " +sheetName + "";&lt;br /&gt;                oSheet.get_Range("A1", "B2").Font.Bold = true;&lt;br /&gt;                oSheet.get_Range("A1", "B2").Font.Color = System.Drawing.ColorTranslator.ToWin32(System.Drawing.Color.DarkBlue);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                // Process the DataTable into the Excel&lt;br /&gt;                DataTable dt = dtSource;&lt;br /&gt;&lt;br /&gt;                int startIndex = 5;&lt;br /&gt;                int rowCount = 5;&lt;br /&gt;                foreach (DataRow dr in dt.Rows)&lt;br /&gt;                {&lt;br /&gt;                    rowCount += 1;&lt;br /&gt;                    for (int i = 1; i &lt; dt.Columns.Count + 1; i++)&lt;br /&gt;                    {&lt;br /&gt;                        // Add the header the first time through&lt;br /&gt;                        if (rowCount == (startIndex+1))&lt;br /&gt;                        {&lt;br /&gt;                            oSheet.Cells[startIndex, i] = dt.Columns[i - 1].ColumnName;&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                        // coversion for the zero values&lt;br /&gt;                        if ((Convert.ToString(dr[i - 1]) == "0.00" || Convert.ToString(dr[i - 1]) == string.Empty) &amp;&amp; !NonHypen.Contains(rowCount))&lt;br /&gt;                            oSheet.Cells[rowCount, i] = "-";&lt;br /&gt;                        else&lt;br /&gt;                            oSheet.Cells[rowCount, i] = dr[i - 1].ToString();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                        // Custom Formatting&lt;br /&gt;&lt;br /&gt;                        // Resize the columns&lt;br /&gt;                        oRange = oSheet.get_Range(oSheet.Cells[1, 1],&lt;br /&gt;                                      oSheet.Cells[rowCount, dt.Columns.Count + 1]); // Additional column for the aggregate-sum&lt;br /&gt;                        oRange.EntireColumn.AutoFit();&lt;br /&gt;&lt;br /&gt;                        oRange.Borders.LineStyle = MyExcel.XlLineStyle.xlContinuous;&lt;br /&gt;                        oRange.Borders.Color = System.Drawing.ColorTranslator.ToWin32(System.Drawing.Color.LightSteelBlue);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                        oSheet.get_Range(oSheet.Cells[startIndex, 1], oSheet.Cells[1, dt.Columns.Count]).Font.Bold = true;&lt;br /&gt;                        oSheet.get_Range(oSheet.Cells[1, 1], oSheet.Cells[1, dt.Columns.Count]).Font.Italic = true;&lt;br /&gt;                        oSheet.get_Range(oSheet.Cells[1, 1], oSheet.Cells[1, dt.Columns.Count]).Font.Size = 11;&lt;br /&gt;&lt;br /&gt;                        oSheet.get_Range(oSheet.Cells[rowCount, dt.Columns.Count], oSheet.Cells[rowCount, dt.Columns.Count]).HorizontalAlignment = MyExcel.XlHAlign.xlHAlignCenter;&lt;br /&gt;&lt;br /&gt;                        if (CustomIndex.Contains(rowCount))&lt;br /&gt;                        {&lt;br /&gt;                            oSheet.get_Range(oSheet.Cells[rowCount, 1], oSheet.Cells[rowCount, dt.Columns.Count]).Font.Bold = true;&lt;br /&gt;                            oSheet.get_Range(oSheet.Cells[rowCount, 1], oSheet.Cells[rowCount, dt.Columns.Count]).Font.Italic = true;&lt;br /&gt;                            oSheet.get_Range(oSheet.Cells[rowCount, 1], oSheet.Cells[rowCount, dt.Columns.Count]).Font.Size = 11;&lt;br /&gt;                            oSheet.get_Range(oSheet.Cells[rowCount, 1], oSheet.Cells[rowCount, dt.Columns.Count]).Font.Color = System.Drawing.ColorTranslator.ToWin32(System.Drawing.Color.DarkBlue);&lt;br /&gt;                            oSheet.get_Range(oSheet.Cells[rowCount, dt.Columns.Count], oSheet.Cells[rowCount, dt.Columns.Count]).HorizontalAlignment = MyExcel.XlHAlign.xlHAlignCenter;&lt;br /&gt;                            oSheet.get_Range(oSheet.Cells[rowCount, 1], oSheet.Cells[rowCount, i]).Borders.LineStyle = MyExcel.XlLineStyle.xlDouble;&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                        // End of Custom Formatting&lt;br /&gt;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;               &lt;br /&gt;                &lt;br /&gt;                // array for the excel column heads&lt;br /&gt;                string[] array = { "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BO", "BP", "BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ" };&lt;br /&gt;                int iArrayIndex = 0;&lt;br /&gt;&lt;br /&gt;                // Applying formulae&lt;br /&gt;                for (int i = 2; i &lt; dt.Columns.Count + 2; i++)&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                    // Total_Revenue_A&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[14, i], oSheet.Cells[14, i]).Formula = "=sum(" + array[iArrayIndex] + "7:" + array[iArrayIndex] + "13)";&lt;br /&gt;&lt;br /&gt;                    // Total_Employ_Cost_B&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[40, i], oSheet.Cells[40, i]).Formula = "=sum(" + array[iArrayIndex] + "15:" + array[iArrayIndex] + "39)";&lt;br /&gt;&lt;br /&gt;                    // PerCentage_Employ_Cost_Per_Revenue&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[41, i], oSheet.Cells[41, i]).Formula = "=(" + array[iArrayIndex] + "40/" + array[iArrayIndex] + "14)";&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[41, i], oSheet.Cells[41, i]).NumberFormat = "##.##%";&lt;br /&gt;&lt;br /&gt;                    // Total_Establis_OtherCost_C&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[88, i], oSheet.Cells[88, i]).Formula = "=sum(" + array[iArrayIndex] + "42:" + array[iArrayIndex] + "87)";&lt;br /&gt;&lt;br /&gt;                    // Total_Cost_D_SumOf_B_Plus_C&lt;br /&gt;&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[89, i], oSheet.Cells[89, i]).Formula = "=(" + array[iArrayIndex] + "88+" + array[iArrayIndex] + "40)";&lt;br /&gt;&lt;br /&gt;                    // Gross_Profit_EBIT&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[90, i], oSheet.Cells[90, i]).Formula = "=(" + array[iArrayIndex] + "14-" + array[iArrayIndex] + "89)";&lt;br /&gt;&lt;br /&gt;                    // Gross_Profit_EBIT without CSG cost&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[91, i], oSheet.Cells[91, i]).Formula = "=(" + array[iArrayIndex] + "40+" + array[iArrayIndex] + "90+" + array[iArrayIndex] + "88)";&lt;br /&gt;&lt;br /&gt;                    // Netprofit&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[96, i], oSheet.Cells[96, i]).Formula = "=(" + array[iArrayIndex] + "14-" + array[iArrayIndex] + "89-" + array[iArrayIndex] + "92-" + array[iArrayIndex] + "93-" + array[iArrayIndex] + "94-" + array[iArrayIndex] + "95)";&lt;br /&gt;&lt;br /&gt;                    if(iArrayIndex &lt; dt.Columns.Count)&lt;br /&gt;                    iArrayIndex++;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                // Aggregate Column&lt;br /&gt;                for (int k = 7; k &lt;= 97; k++)&lt;br /&gt;                {&lt;br /&gt;                    oSheet.get_Range(oSheet.Cells[k, (dt.Columns.Count + 1)], oSheet.Cells[k, (dt.Columns.Count + 1)]).Formula = "=sum(B" + k + ":"+array[(dt.Columns.Count-2)]+ k + ")";&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                // Set-Header/Column Settings&lt;br /&gt;&lt;br /&gt;                oSheet.get_Range(oSheet.Cells[5, (dt.Columns.Count + 1)], oSheet.Cells[5, (dt.Columns.Count + 1)]).Value2 = "Total";&lt;br /&gt;                oSheet.get_Range(oSheet.Cells[5, (dt.Columns.Count + 1)], oSheet.Cells[97, (dt.Columns.Count + 1)]).Interior.Color =  System.Drawing.ColorTranslator.ToWin32(System.Drawing.Color.LightSteelBlue);&lt;br /&gt;                oSheet.get_Range(oSheet.Cells[5, (dt.Columns.Count + 1)], oSheet.Cells[97, (dt.Columns.Count + 1)]).Borders.LineStyle = MyExcel.XlLineStyle.xlDouble;&lt;br /&gt;                oSheet.get_Range(oSheet.Cells[5, (dt.Columns.Count + 1)], oSheet.Cells[97, (dt.Columns.Count + 1)]).Borders.Color =  System.Drawing.ColorTranslator.ToWin32(System.Drawing.Color.LightSteelBlue);&lt;br /&gt;                oSheet.get_Range(oSheet.Cells[5, (dt.Columns.Count + 1)], oSheet.Cells[97, (dt.Columns.Count + 1)]).Font.Bold = true;&lt;br /&gt;&lt;br /&gt;                // Header-Line&lt;br /&gt;&lt;br /&gt;                oSheet.get_Range(oSheet.Cells[5, 1], oSheet.Cells[5, (dt.Columns.Count + 1)]).Borders.LineStyle = MyExcel.XlLineStyle.xlDouble;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                // Report Footer&lt;br /&gt;&lt;br /&gt;                MyExcel.Range FooterColumn = oSheet.get_Range(oSheet.Cells[100, 1], oSheet.Cells[100, 1]);&lt;br /&gt;                FooterColumn.Font.Bold = true;&lt;br /&gt;                FooterColumn.Font.Italic = true;&lt;br /&gt;                FooterColumn.Font.Color = System.Drawing.ColorTranslator.ToWin32(System.Drawing.Color.DarkBlue);&lt;br /&gt;                FooterColumn.Value2 = "Report Generated by MIS_Finance - " + DateTime.Now.ToShortDateString();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                // Text-Alignment&lt;br /&gt;&lt;br /&gt;                oSheet.get_Range(oSheet.Cells[5, 2], oSheet.Cells[96, (dt.Columns.Count + 1)]).HorizontalAlignment = MyExcel.XlHAlign.xlHAlignCenter;&lt;br /&gt;&lt;br /&gt;               &lt;br /&gt;                // Save the sheet and close&lt;br /&gt;                oSheet = null;&lt;br /&gt;                oRange = null;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                if (blnFirstSheet)&lt;br /&gt;                {&lt;br /&gt;                    oWB.SaveAs(ExcelPath, MyExcel.XlFileFormat.xlWorkbookNormal,&lt;br /&gt;                        Type.Missing, Type.Missing, Type.Missing, Type.Missing,&lt;br /&gt;                        MyExcel.XlSaveAsAccessMode.xlExclusive,&lt;br /&gt;                        Type.Missing, Type.Missing, Type.Missing,&lt;br /&gt;                        Type.Missing, Type.Missing);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    oWB.Save();&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                oWB.Close(Type.Missing, Type.Missing, Type.Missing);&lt;br /&gt;                oWB = null;&lt;br /&gt;                oXL.Quit();&lt;br /&gt;                &lt;br /&gt;                // No-Errors&lt;br /&gt;                return string.Empty;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show("Invalid Operation : \n" + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);&lt;br /&gt;                DataLayer.ExecuteExcepLogProcedure(ex.ToString());&lt;br /&gt;                return "Error " + ex.Message;&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                // Clean up&lt;br /&gt;                // NOTE: When in release mode, this does the trick&lt;br /&gt;                GC.WaitForPendingFinalizers();&lt;br /&gt;                GC.Collect();&lt;br /&gt;                GC.WaitForPendingFinalizers();&lt;br /&gt;                GC.Collect();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-688295860327666973?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/688295860327666973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/02/how-to-write-custom-formatted-excel-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/688295860327666973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/688295860327666973'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/02/how-to-write-custom-formatted-excel-in.html' title='How to write custom formatted excel in C# from dataTable'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8855311184218229555</id><published>2011-02-03T03:13:00.000-08:00</published><updated>2011-02-03T03:13:15.902-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Encryption'/><title type='text'>DES encryption in C#</title><content type='html'>const string DESKey = "AQWSEDRF";&lt;br /&gt;const string DESIV = "HGFEDCBA";&lt;br /&gt;&lt;br /&gt;public static string DESDecrypt(string stringToDecrypt)&lt;br /&gt;{&lt;br /&gt;    byte[] key;&lt;br /&gt;    byte[] IV;&lt;br /&gt;    byte[] inputByteArray;&lt;br /&gt;    key = Convert2ByteArray(DESKey);&lt;br /&gt;    IV = Convert2ByteArray(DESIV);&lt;br /&gt;    int len = stringToDecrypt.Length;&lt;br /&gt;    inputByteArray = Convert.FromBase64String(stringToDecrypt);&lt;br /&gt;    DESCryptoServiceProvider des = new DESCryptoServiceProvider();&lt;br /&gt;    MemoryStream ms = new MemoryStream();&lt;br /&gt;    CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write);&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;        cs.Write(inputByteArray, 0, inputByteArray.Length);&lt;br /&gt;        cs.FlushFinalBlock();&lt;br /&gt;        Encoding encoding = Encoding.UTF8;&lt;br /&gt;        return encoding.GetString(ms.ToArray());&lt;br /&gt;    }&lt;br /&gt;    catch (System.Exception ex)&lt;br /&gt;    {&lt;br /&gt;        throw ex;&lt;br /&gt;    }&lt;br /&gt;    finally&lt;br /&gt;    {&lt;br /&gt;        ms.Close();&lt;br /&gt;        cs.Close();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public static string DESEncrypt(string stringToEncrypt)&lt;br /&gt;{&lt;br /&gt;    byte[] key;&lt;br /&gt;    byte[] IV;&lt;br /&gt;    byte[] inputByteArray;&lt;br /&gt;    key = Convert2ByteArray(DESKey);&lt;br /&gt;    IV = Convert2ByteArray(DESIV);&lt;br /&gt;    inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt);&lt;br /&gt;    DESCryptoServiceProvider des = new DESCryptoServiceProvider();&lt;br /&gt;    MemoryStream ms = new MemoryStream();&lt;br /&gt;    CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write);&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;        cs.Write(inputByteArray, 0, inputByteArray.Length);&lt;br /&gt;        cs.FlushFinalBlock();&lt;br /&gt;        return Convert.ToBase64String(ms.ToArray());&lt;br /&gt;    }&lt;br /&gt;    catch (System.Exception ex)&lt;br /&gt;    {&lt;br /&gt;        throw ex;&lt;br /&gt;    }&lt;br /&gt;    finally&lt;br /&gt;    {&lt;br /&gt;        ms.Close();&lt;br /&gt;        cs.Close();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static byte[] Convert2ByteArray(string strInput)&lt;br /&gt;{&lt;br /&gt;    int intCounter; char[] arrChar;&lt;br /&gt;    arrChar = strInput.ToCharArray();&lt;br /&gt;    byte[] arrByte = new byte[arrChar.Length];&lt;br /&gt;    for (intCounter = 0; intCounter &lt; arrByte.Length; intCounter++)&lt;br /&gt;        arrByte[intCounter] = Convert.ToByte(arrChar[intCounter]);&lt;br /&gt;    return arrByte;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8855311184218229555?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8855311184218229555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/02/des-encryption-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8855311184218229555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8855311184218229555'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/02/des-encryption-in-c.html' title='DES encryption in C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-7775026038708882999</id><published>2011-02-03T03:10:00.001-08:00</published><updated>2011-02-03T03:10:59.325-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ZipFile'/><title type='text'>Zip File or Folder in C#</title><content type='html'>using ICSharpCode.SharpZipLib.Zip;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;ZipOutputStream zos = null;&lt;br /&gt;protected void Button1_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    string[] pathCollection = new string[2];&lt;br /&gt;    PathCellction[0] = "c:\\folder1";&lt;br /&gt;    PathCellction[1] = "c:\\folder2";  &lt;br /&gt;    StartZip(pathCollection, "filename"); &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void StartZip(string[] pathCollection, string strFileName)&lt;br /&gt;{&lt;br /&gt;    MemoryStream ms;&lt;br /&gt;    Response.ContentType = "application/octet-stream";&lt;br /&gt;    strFileName = HttpUtility.UrlEncode(strFileName).Replace('+', ' ');&lt;br /&gt;    Response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName + ".zip");&lt;br /&gt;    ms = new MemoryStream();&lt;br /&gt;    zos = new ZipOutputStream(ms);&lt;br /&gt;    addZipEntry(pathCollection);&lt;br /&gt;    ms.Close();&lt;br /&gt;    zos.Finish();&lt;br /&gt;    zos.Close();&lt;br /&gt;    Response.Clear();&lt;br /&gt;    Response.BinaryWrite(ms.ToArray());&lt;br /&gt;    Response.End();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void addZipEntry(string[] pathCollection)&lt;br /&gt;{&lt;br /&gt;    for (int i = 0; i &lt; pathCollection.Length; i++)&lt;br /&gt;    {&lt;br /&gt;        string strPath = pathCollection[i];&lt;br /&gt;        addZipEntry(strPath, strPath.LastIndexOf("\\") + 1);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void addZipEntry(string strPath, int baseIndex)&lt;br /&gt;{&lt;br /&gt;    DirectoryInfo di = new DirectoryInfo(strPath);&lt;br /&gt;    foreach (DirectoryInfo item in di.GetDirectories())&lt;br /&gt;    {&lt;br /&gt;        addZipEntry(item.FullName, baseIndex);&lt;br /&gt;    }&lt;br /&gt;    foreach (FileInfo item in di.GetFiles())&lt;br /&gt;    {&lt;br /&gt;        FileStream fs = File.OpenRead(item.FullName);&lt;br /&gt;        byte[] buffer = new byte[fs.Length];&lt;br /&gt;        fs.Read(buffer, 0, buffer.Length);&lt;br /&gt;        string strEntryName = item.FullName.Remove(0, baseIndex);&lt;br /&gt;        ZipEntry entry = new ZipEntry(strEntryName);&lt;br /&gt;        zos.PutNextEntry(entry);&lt;br /&gt;        zos.Write(buffer, 0, buffer.Length);&lt;br /&gt;        fs.Close();&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-7775026038708882999?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/7775026038708882999/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/02/zip-file-or-folder-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7775026038708882999'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7775026038708882999'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2011/02/zip-file-or-folder-in-c.html' title='Zip File or Folder in C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8491826079003425186</id><published>2010-09-17T05:41:00.000-07:00</published><updated>2010-09-17T05:41:23.240-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Copy Folder+C#'/><title type='text'>Copy complete folder with respective folder hierarchy to another location</title><content type='html'>public class FileSystem{&lt;br /&gt;        // Copy directory structure recursively&lt;br /&gt;&lt;br /&gt;        public static void copyDirectory(string Src,string Dst){&lt;br /&gt;            String[] Files;&lt;br /&gt;&lt;br /&gt;            if(Dst[Dst.Length-1]!=Path.DirectorySeparatorChar) &lt;br /&gt;                Dst+=Path.DirectorySeparatorChar;&lt;br /&gt;            if(!Directory.Exists(Dst)) Directory.CreateDirectory(Dst);&lt;br /&gt;            Files=Directory.GetFileSystemEntries(Src);&lt;br /&gt;            foreach(string Element in Files){&lt;br /&gt;                // Sub directories&lt;br /&gt;&lt;br /&gt;                if(Directory.Exists(Element)) &lt;br /&gt;                    copyDirectory(Element,Dst+Path.GetFileName(Element));&lt;br /&gt;                // Files in directory&lt;br /&gt;&lt;br /&gt;                else &lt;br /&gt;                    File.Copy(Element,Dst+Path.GetFileName(Element),true);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8491826079003425186?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8491826079003425186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/09/copy-complete-folder-with-respective.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8491826079003425186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8491826079003425186'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/09/copy-complete-folder-with-respective.html' title='Copy complete folder with respective folder hierarchy to another location'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6723897676720893260</id><published>2010-09-02T23:17:00.001-07:00</published><updated>2010-09-02T23:17:14.280-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How to write XML File from the Object Collection'/><title type='text'>How to write XML File from the Object Collection</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Web;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;using System.Xml;&lt;br /&gt;&lt;br /&gt;public partial class WriteProductXMLFile : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;    protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        if (!IsPostBack)&lt;br /&gt;        {&lt;br /&gt;            WriteProducts("9955");&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public System.Collections.IEnumerable CreateProducts()&lt;br /&gt;    {&lt;br /&gt;        List&lt;Product&gt; products = new List&lt;Product&gt;();&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;        products.Add(Product.Create("1", "AAAA"));&lt;br /&gt;        products.Add(Product.Create("2", "BBBB"));&lt;br /&gt;        products.Add(Product.Create("3", "JJJJJ"));&lt;br /&gt;        products.Add(Product.Create("4", "AAAKKKA"));&lt;br /&gt;        products.Add(Product.Create("5", "YYYYY"));&lt;br /&gt;        products.Add(Product.Create("6", "PPPPP"));&lt;br /&gt;        products.Add(Product.Create("7", "MMMMM"));&lt;br /&gt;        products.Add(Product.Create("8", "TTTTT"));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        return products;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    protected void WriteProducts(string CustomerID)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        System.Collections.IEnumerable products = CreateProducts();&lt;br /&gt;&lt;br /&gt;        string FileName = "Products_" + CustomerID+".xml";&lt;br /&gt;&lt;br /&gt;        string FilePath = Server.MapPath(FileName);&lt;br /&gt;&lt;br /&gt;        if (System.IO.File.Exists(FilePath))&lt;br /&gt;        {&lt;br /&gt;            System.IO.File.Delete(FilePath);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        XmlTextWriter XmlWriter = new XmlTextWriter(FilePath, null);&lt;br /&gt;        &lt;br /&gt;        XmlWriter.WriteStartDocument();&lt;br /&gt;        XmlWriter.WriteComment("Product XML.");&lt;br /&gt;        XmlWriter.WriteStartElement("Products of Customer: ID");&lt;br /&gt;&lt;br /&gt;        foreach (Product prod in products)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            XmlWriter.WriteStartElement("Product");&lt;br /&gt;            XmlWriter.WriteElementString("ProductID", prod.ProductID);&lt;br /&gt;            XmlWriter.WriteElementString("ProductImage", prod.ProductImage);&lt;br /&gt;            XmlWriter.WriteEndElement();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        XmlWriter.WriteEndDocument();&lt;br /&gt;        XmlWriter.Flush();&lt;br /&gt;        XmlWriter.Close();&lt;br /&gt;        &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    # region Internal Class&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public class Product&lt;br /&gt;    {&lt;br /&gt;        public static Product Create(string productID,&lt;br /&gt;                                    string productImage)&lt;br /&gt;        {&lt;br /&gt;            Product product = new Product();&lt;br /&gt;&lt;br /&gt;            product.ProductID = productID;&lt;br /&gt;            product.ProductImage = productImage;&lt;br /&gt;&lt;br /&gt;            return product;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private string _productID;&lt;br /&gt;       &lt;br /&gt;        public string ProductID&lt;br /&gt;        {&lt;br /&gt;            get { return _productID; }&lt;br /&gt;            set { _productID = value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private string _Image;&lt;br /&gt;        public string ProductImage&lt;br /&gt;        {&lt;br /&gt;            get { return _Image; }&lt;br /&gt;            set { _Image = value; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    #endregion&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6723897676720893260?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6723897676720893260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/09/how-to-write-xml-file-from-object.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6723897676720893260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6723897676720893260'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/09/how-to-write-xml-file-from-object.html' title='How to write XML File from the Object Collection'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6983358003265817727</id><published>2010-08-25T23:50:00.000-07:00</published><updated>2010-08-25T23:50:19.248-07:00</updated><title type='text'>Extract SubString From Delimitered Chars</title><content type='html'>public string ExtractSubStringFromDelimiterChar(string strValue, char Char1, char Char2)&lt;br /&gt;{&lt;br /&gt; if (string.IsNullOrEmpty(strValue)) {&lt;br /&gt;  return strValue;&lt;br /&gt;&lt;br /&gt; } else {&lt;br /&gt;  Int16 iStart = strValue.IndexOf(Char1);&lt;br /&gt;  Int16 iEnd = strValue.LastIndexOf(Char2);&lt;br /&gt;&lt;br /&gt;  if ((iStart &gt;= 0 &amp; iEnd &gt; iStart)) {&lt;br /&gt;   return strValue.Substring(iStart + 1, (iEnd) - (iStart + 1));&lt;br /&gt;  } else {&lt;br /&gt;   return strValue;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;VB.Net&lt;br /&gt;&lt;br /&gt; Public Function ExtractSubStringFromDelimiterChar(ByVal strValue As String, ByVal Char1 As Char, ByVal Char2 As Char) As String&lt;br /&gt;        If String.IsNullOrEmpty(strValue) Then&lt;br /&gt;            Return strValue&lt;br /&gt;        Else&lt;br /&gt;&lt;br /&gt;            Dim iStart As Int16 = strValue.IndexOf(Char1)&lt;br /&gt;            Dim iEnd As Int16 = strValue.LastIndexOf(Char2)&lt;br /&gt;&lt;br /&gt;            If (iStart &gt;= 0 And iEnd &gt; iStart) Then&lt;br /&gt;                Return strValue.Substring(iStart + 1, (iEnd) - (iStart + 1))&lt;br /&gt;            Else&lt;br /&gt;                Return strValue&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;    End Function&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6983358003265817727?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6983358003265817727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/extract-substring-from-delimitered_25.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6983358003265817727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6983358003265817727'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/extract-substring-from-delimitered_25.html' title='Extract SubString From Delimitered Chars'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-7114776819285735001</id><published>2010-08-25T23:49:00.000-07:00</published><updated>2010-08-25T23:49:03.943-07:00</updated><title type='text'>Extract SubString From the Delimitered String</title><content type='html'>public string ExtractSubStringFromDelimiterString(string strValue, string s1, string s2)&lt;br /&gt;{&lt;br /&gt; if (string.IsNullOrEmpty(strValue)) {&lt;br /&gt;  return strValue;&lt;br /&gt;&lt;br /&gt; } else {&lt;br /&gt;  Int16 iStart = strValue.IndexOf(s1);&lt;br /&gt;  Int16 iEnd = strValue.LastIndexOf(s2);&lt;br /&gt;&lt;br /&gt;  if ((iStart &gt;= 0 &amp; iEnd &gt; iStart)) {&lt;br /&gt;   return strValue.Substring(iStart + 1, (iEnd) - (iStart + 1));&lt;br /&gt;  } else {&lt;br /&gt;   return strValue;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;VB.Net&lt;br /&gt;&lt;br /&gt; Public Function ExtractSubStringFromDelimiterString(ByVal strValue As String, ByVal s1 As String, ByVal s2 As String) As String&lt;br /&gt;        If String.IsNullOrEmpty(strValue) Then&lt;br /&gt;            Return strValue&lt;br /&gt;        Else&lt;br /&gt;&lt;br /&gt;            Dim iStart As Int16 = strValue.IndexOf(s1)&lt;br /&gt;            Dim iEnd As Int16 = strValue.LastIndexOf(s2)&lt;br /&gt;&lt;br /&gt;            If (iStart &gt;= 0 And iEnd &gt; iStart) Then&lt;br /&gt;                Return strValue.Substring(iStart + 1, (iEnd) - (iStart + 1))&lt;br /&gt;            Else&lt;br /&gt;                Return strValue&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            End If&lt;br /&gt;        End If&lt;br /&gt;&lt;br /&gt;    End Function&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-7114776819285735001?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/7114776819285735001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/extract-substring-from-delimitered.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7114776819285735001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7114776819285735001'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/extract-substring-from-delimitered.html' title='Extract SubString From the Delimitered String'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3539798918848895300</id><published>2010-08-24T01:27:00.001-07:00</published><updated>2010-08-24T01:27:16.160-07:00</updated><title type='text'>Get File Attributes of File residing on FTP Server</title><content type='html'>private static FTPFileMetaData GetMetaDataFTPFile(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName, string strFileName)&lt;br /&gt;        {&lt;br /&gt;            FTPFileMetaData metaData = new FTPFileMetaData();&lt;br /&gt;            FtpWebRequest reqFTP;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            long fileSize = 0;&lt;br /&gt;&lt;br /&gt;            if (!ftpServerIP.Contains("ftp://"))&lt;br /&gt;            {&lt;br /&gt;                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" +&lt;br /&gt;                                        ftpServerIP + "/" + strFolderName + "/" + strFileName));&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP +&lt;br /&gt;                                         "/" + strFolderName + "/" + strFileName));&lt;br /&gt;            }&lt;br /&gt;            reqFTP.Method = WebRequestMethods.Ftp.GetDateTimestamp;&lt;br /&gt;            reqFTP.UseBinary = true;&lt;br /&gt;            reqFTP.KeepAlive = false;&lt;br /&gt;            reqFTP.Credentials = new NetworkCredential(ftpUserID,&lt;br /&gt;                                                            ftpPassword);&lt;br /&gt;            FtpWebResponse response;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                response = (FtpWebResponse)reqFTP.GetResponse();&lt;br /&gt;&lt;br /&gt;                DateTime lastModified = response.LastModified;&lt;br /&gt;&lt;br /&gt;                metaData.FileName = strFileName;&lt;br /&gt;                metaData.ModifiedTime = lastModified;&lt;br /&gt;                Stream ftpStream = response.GetResponseStream();&lt;br /&gt;                fileSize = response.ContentLength;&lt;br /&gt;                metaData.FileLength = fileSize;&lt;br /&gt;                metaData.FileLength = GetFTPFileSize(ftpServerIP, ftpUserID, ftpPassword, strFolderName, strFileName);&lt;br /&gt;&lt;br /&gt;                return metaData;&lt;br /&gt;            }&lt;br /&gt;            catch(Exception ex)&lt;br /&gt;            {&lt;br /&gt;                BAL.WriteLog("Error in FTPModule for MetaData " + ex.ToString() + "-" + DateTime.Now);&lt;br /&gt;                return metaData;&lt;br /&gt;            }&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3539798918848895300?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3539798918848895300/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/get-file-attributes-of-file-residing-on.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3539798918848895300'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3539798918848895300'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/get-file-attributes-of-file-residing-on.html' title='Get File Attributes of File residing on FTP Server'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8253396460069513183</id><published>2010-08-24T01:26:00.001-07:00</published><updated>2010-08-24T01:26:21.204-07:00</updated><title type='text'>Get the File List of Files on FTP Server</title><content type='html'>public static FTPFileMetaData GetFTPFileList(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName, string FileName)&lt;br /&gt;        {&lt;br /&gt;            string[] downloadFiles;&lt;br /&gt;            StringBuilder result = new StringBuilder();&lt;br /&gt;            FtpWebRequest reqFTP;&lt;br /&gt;            FTPFileMetaData metaDataOfReFile = new FTPFileMetaData();&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                if (!ftpServerIP.Contains("ftp://"))&lt;br /&gt;                {&lt;br /&gt;                    reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" +&lt;br /&gt;                                            ftpServerIP + "/" + strFolderName + "/" + FileName));&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpServerIP +&lt;br /&gt;                                             "/" + strFolderName + "/" + FileName ));&lt;br /&gt;                }&lt;br /&gt;                reqFTP.UseBinary = true;&lt;br /&gt;                reqFTP.KeepAlive = false;&lt;br /&gt;                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);&lt;br /&gt;                reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;&lt;br /&gt;                WebResponse response = reqFTP.GetResponse();&lt;br /&gt;                StreamReader reader = new StreamReader(response.GetResponseStream());&lt;br /&gt;                //MessageBox.Show(reader.ReadToEnd());&lt;br /&gt;                string line = reader.ReadLine();&lt;br /&gt;                while (line != null)&lt;br /&gt;                {&lt;br /&gt;                    result.Append(line);&lt;br /&gt;                    result.Append("\n");&lt;br /&gt;                    line = reader.ReadLine();&lt;br /&gt;                }&lt;br /&gt;                result.Remove(result.ToString().LastIndexOf('\n'), 1);&lt;br /&gt;                reader.Close();&lt;br /&gt;                response.Close();&lt;br /&gt;                //MessageBox.Show(response.StatusDescription);&lt;br /&gt;                downloadFiles = result.ToString().Split('\n');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                foreach (string s in downloadFiles)&lt;br /&gt;                {&lt;br /&gt;                    metaDataOfReFile = GetMetaDataFTPFile(ftpServerIP, ftpUserID, ftpPassword, strFolderName, s);&lt;br /&gt;                    &lt;br /&gt;&lt;br /&gt;#if (Diagnostics)&lt;br /&gt;&lt;br /&gt;                    BAL.WriteTrackLog("Fetching meta data of FTP File in Re-DownloadMode - '" + s + "'" + "  " + DateTime.Now);&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                return metaDataOfReFile;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                BAL.WriteLog("Error in FTPModule for FTPList for ReDownload" + ex.ToString() + "-" + DateTime.Now);&lt;br /&gt;                return metaDataOfReFile;&lt;br /&gt;            }&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8253396460069513183?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8253396460069513183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/get-file-list-of-files-on-ftp-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8253396460069513183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8253396460069513183'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/get-file-list-of-files-on-ftp-server.html' title='Get the File List of Files on FTP Server'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2230953068744897034</id><published>2010-08-24T01:24:00.001-07:00</published><updated>2010-08-24T01:24:55.694-07:00</updated><title type='text'>Get the File Size of File residing on FTP Server</title><content type='html'>private static long GetFTPFileSize(string ftpServerIP, string ftpUserID, string ftpPassword, string strFolderName, string strFileName)&lt;br /&gt;        {&lt;br /&gt;            FtpWebRequest reqFTP;&lt;br /&gt;            long fileSize = 0;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + strFolderName + "/" + strFileName));&lt;br /&gt;                reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;&lt;br /&gt;                reqFTP.UseBinary = true;&lt;br /&gt;                reqFTP.KeepAlive = false;&lt;br /&gt;                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);&lt;br /&gt;                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();&lt;br /&gt;                Stream ftpStream = response.GetResponseStream();&lt;br /&gt;                fileSize = response.ContentLength;&lt;br /&gt;&lt;br /&gt;                ftpStream.Close();&lt;br /&gt;                response.Close();&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                BAL.WriteLog("Error in FTPModule for FileSize " + ex.ToString() + "-" + DateTime.Now);&lt;br /&gt;            }&lt;br /&gt;            return fileSize;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2230953068744897034?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2230953068744897034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/get-file-size-of-file-residing-on-ftp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2230953068744897034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2230953068744897034'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/get-file-size-of-file-residing-on-ftp.html' title='Get the File Size of File residing on FTP Server'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-9187567474297398431</id><published>2010-08-18T00:07:00.001-07:00</published><updated>2010-08-18T00:07:48.429-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RowFilter'/><title type='text'>Filter DataTable with Select method of DataTable</title><content type='html'>Private Function GetRowsByBlockIdFilter(ByVal dt As DataTable, ByVal blockId As String) As DataTable&lt;br /&gt;&lt;br /&gt;        Dim table As DataTable = dt.Copy()&lt;br /&gt;        dt.Rows.Clear()&lt;br /&gt;&lt;br /&gt;        Dim expression As String&lt;br /&gt;        expression = "blockId='" + blockId.Trim() + "' "&lt;br /&gt;        Dim foundRows() As DataRow&lt;br /&gt;&lt;br /&gt;        ' Use the Select method to find all rows matching the filter.&lt;br /&gt;        foundRows = table.Select(expression)&lt;br /&gt;&lt;br /&gt;        Dim i As Integer&lt;br /&gt;        ' Print column 0 of each returned row.&lt;br /&gt;        For i = 0 To foundRows.GetUpperBound(0)&lt;br /&gt;            dt.ImportRow(foundRows(i))&lt;br /&gt;&lt;br /&gt;        Next i&lt;br /&gt;&lt;br /&gt;        Return dt&lt;br /&gt;    End Function&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-9187567474297398431?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/9187567474297398431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/filter-datatable-with-select-method-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/9187567474297398431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/9187567474297398431'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/filter-datatable-with-select-method-of.html' title='Filter DataTable with Select method of DataTable'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6939590243820871798</id><published>2010-08-17T23:44:00.001-07:00</published><updated>2010-08-17T23:44:55.317-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Remove Cache in ASP.net'/><title type='text'>Remove Cache in ASP.net</title><content type='html'>For Each de As DictionaryEntry In HttpContext.Current.Cache&lt;br /&gt;&lt;br /&gt;HttpContext.Current.Cache.Remove(DirectCast(de.Key, String))&lt;br /&gt;&lt;br /&gt;Next&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6939590243820871798?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6939590243820871798/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/remove-cache-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6939590243820871798'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6939590243820871798'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/08/remove-cache-in-aspnet.html' title='Remove Cache in ASP.net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-1094245751793310297</id><published>2010-05-08T02:23:00.000-07:00</published><updated>2010-05-08T02:24:20.469-07:00</updated><title type='text'>How to get the ContentType of the File</title><content type='html'>private string GetContentType(string fileName)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;        string contentType = "application/octetstream";&lt;br /&gt;&lt;br /&gt;        string ext = System.IO.Path.GetExtension(fileName).ToLower();&lt;br /&gt;&lt;br /&gt;        Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);&lt;br /&gt;&lt;br /&gt;        if (registryKey != null &amp;&amp; registryKey.GetValue("Content Type") != null)&lt;br /&gt;&lt;br /&gt;        contentType = registryKey.GetValue("Content Type").ToString();&lt;br /&gt;&lt;br /&gt;        return contentType;&lt;br /&gt;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-1094245751793310297?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/1094245751793310297/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/05/how-to-get-contenttype-of-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1094245751793310297'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1094245751793310297'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/05/how-to-get-contenttype-of-file.html' title='How to get the ContentType of the File'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2679041193766330133</id><published>2010-03-23T04:22:00.000-07:00</published><updated>2010-03-23T04:23:28.181-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Recursive_Files'/><title type='text'>Recursive_Files_Search_In_CSharp</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.IO;&lt;br /&gt;&lt;br /&gt;namespace Trans829115.BLL&lt;br /&gt;{&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;    /// RecursiveFilesSearch from FolderPath/DrivePath&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    /// &lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;    public class RecursiveFilesSearch&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;         static private List&lt;string&gt; FilesFound  = new List&lt;string&gt;(); // DirectSearch(Global)&lt;br /&gt;        &lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        ///  &lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public RecursiveFilesSearch()&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private string PaddAsDirectoryPath(string path)&lt;br /&gt;        {&lt;br /&gt;            if(string.IsNullOrEmpty(path)) return string.Empty;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            if(path.Substring((path.Length-2))!="\\")&lt;br /&gt;               return path+"\\";&lt;br /&gt;&lt;br /&gt;            return string.Empty;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public enum EnumSourceFilesType&lt;br /&gt;    {&lt;br /&gt;        CS_Files,&lt;br /&gt;        VB_Files&lt;br /&gt;    }&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Get All the files in the respective Folder/Drive&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="SourceDir"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;param name="blnIsValidator"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public List&lt;string&gt; GetAllFileNames(string SourceDir, bool blnIsFileValidator)&lt;br /&gt;        {&lt;br /&gt;            if(!Directory.Exists(SourceDir))&lt;br /&gt;            {&lt;br /&gt;                throw new Exception(string.Format("{0} - is not exists - Please define valid Source Path", SourceDir ));&lt;br /&gt;                return null;&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            SourceDir = PaddAsDirectoryPath(SourceDir);&lt;br /&gt;&lt;br /&gt;            List&lt;string&gt; files = new List&lt;string&gt;();&lt;br /&gt;            &lt;br /&gt;            DirectoryInfo di = new DirectoryInfo(SourceDir);&lt;br /&gt;&lt;br /&gt;            DirectoryInfo[] dirs = di.GetDirectories();&lt;br /&gt;            &lt;br /&gt;            foreach (DirectoryInfo diNext in dirs) &lt;br /&gt;            {&lt;br /&gt;                files.AddRange(DirSearch(diNext.FullName, "*.*", blnIsFileValidator));&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return files;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Specific search on SearchType&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="SourceDir"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;param name="enumSourceType"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public List&lt;string&gt; GetSelectedFileNames(string SourceDir, EnumSourceFilesType enumSourceType, bool blnIsFileValidator)&lt;br /&gt;        {&lt;br /&gt;            if(!Directory.Exists(SourceDir))&lt;br /&gt;            {&lt;br /&gt;                throw new Exception(string.Format("{0} - is not exists - Please define valid Source Path", SourceDir ));&lt;br /&gt;                return null;&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            string searchPattern = "*.*"; // Default&lt;br /&gt;&lt;br /&gt;            switch(enumSourceType)&lt;br /&gt;            {&lt;br /&gt;                case EnumSourceFilesType.CS_Files:&lt;br /&gt;                    searchPattern = "*.cs";&lt;br /&gt;                    break;&lt;br /&gt;                case EnumSourceFilesType.VB_Files:&lt;br /&gt;                    searchPattern = "*.vb";&lt;br /&gt;                    break;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;             SourceDir = PaddAsDirectoryPath(SourceDir);&lt;br /&gt;&lt;br /&gt;            List&lt;string&gt; files = new List&lt;string&gt;();&lt;br /&gt;            &lt;br /&gt;            DirectoryInfo di = new DirectoryInfo(SourceDir);&lt;br /&gt;&lt;br /&gt;            DirectoryInfo[] dirs = di.GetDirectories();&lt;br /&gt;            &lt;br /&gt;            foreach (DirectoryInfo diNext in dirs) &lt;br /&gt;            {&lt;br /&gt;                files.AddRange(DirSearch(diNext.FullName, searchPattern, blnIsFileValidator));&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            return files;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;            private List&lt;string&gt; DirSearch(string sDir, string SearchPattern) &lt;br /&gt;            {&lt;br /&gt;               &lt;br /&gt;                try &lt;br /&gt;             {&lt;br /&gt;                foreach (string d in Directory.GetDirectories(sDir)) &lt;br /&gt;                {&lt;br /&gt;              foreach (string f in Directory.GetFiles(d, SearchPattern)) &lt;br /&gt;              {&lt;br /&gt;                 FilesFound.Add(f);&lt;br /&gt;              }&lt;br /&gt;              DirSearch(d,SearchPattern);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                    return FilesFound;&lt;br /&gt;             }&lt;br /&gt;             catch (System.Exception excpt) &lt;br /&gt;             {&lt;br /&gt;              throw new Exception(excpt.Message);&lt;br /&gt;             }&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;        /// Option to apply FileValidator method&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="sDir"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;param name="SearchPattern"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;param name="blnIsFileValidator"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;         private List&lt;string&gt; DirSearch(string sDir, string SearchPattern, bool blnIsFileValidator) &lt;br /&gt;            {&lt;br /&gt;                &lt;br /&gt;                try &lt;br /&gt;             {&lt;br /&gt;                foreach (string d in Directory.GetDirectories(sDir)) &lt;br /&gt;                {&lt;br /&gt;              foreach (string f in Directory.GetFiles(d, SearchPattern)) &lt;br /&gt;              {&lt;br /&gt;                 if(blnIsFileValidator)&lt;br /&gt;                       {&lt;br /&gt;                           if(ValidateFile(f))&lt;br /&gt;                               FilesFound.Add(f);&lt;br /&gt;                       }&lt;br /&gt;                        else&lt;br /&gt;                       FilesFound.Add(f);&lt;br /&gt;              }&lt;br /&gt;              DirSearch(d, SearchPattern, blnIsFileValidator);&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                    return FilesFound;&lt;br /&gt;             }&lt;br /&gt;             catch (System.Exception excpt) &lt;br /&gt;             {&lt;br /&gt;              return FilesFound; // Intermediate results to pass on&lt;br /&gt;                    throw new Exception(excpt.Message);&lt;br /&gt;             }&lt;br /&gt;            }&lt;br /&gt;/// &lt;summary&gt;&lt;br /&gt;/// check Is File is Valid for Copying&lt;br /&gt;/// &lt;/summary&gt;&lt;br /&gt;/// &lt;param name="file"&gt;&lt;/param&gt;&lt;br /&gt;/// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        private bool ValidateFile(string file)&lt;br /&gt;        {&lt;br /&gt;            file = Path.GetFileName(file);&lt;br /&gt;            if(string.IsNullOrEmpty(file)) return false;&lt;br /&gt;&lt;br /&gt;            if(file.Equals("Program.cs")) return false;&lt;br /&gt;&lt;br /&gt;            if(file.Equals("Program.vb")) return false;&lt;br /&gt;&lt;br /&gt;            if(file.Contains("Designer.cs")) return false;&lt;br /&gt;&lt;br /&gt;            if(file.Contains("Designer.vb")) return false;&lt;br /&gt;&lt;br /&gt;            if(file.Equals("AssemblyInfo.cs")) return false;&lt;br /&gt;&lt;br /&gt;            if(file.Equals("AssemblyInfo.vb")) return false;&lt;br /&gt;&lt;br /&gt;            return true;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2679041193766330133?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2679041193766330133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/03/recursivefilessearchincsharp.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2679041193766330133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2679041193766330133'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/03/recursivefilessearchincsharp.html' title='Recursive_Files_Search_In_CSharp'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3931666159715541740</id><published>2010-02-25T04:44:00.000-08:00</published><updated>2010-02-25T04:45:52.389-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Appling Linq on ADO.net'/><title type='text'>Appling Linq on ADO.net</title><content type='html'>// Marking sql-like queries on datatable with linq&lt;br /&gt;&lt;br /&gt;EnumerableRowCollection&lt;DataRow&gt; query =&lt;br /&gt;from employee in employees.AsEnumerable()&lt;br /&gt;where employee.Field&lt;Decimal&gt;("salary") &gt; 20&lt;br /&gt;orderby employee.Field&lt;Decimal&gt;("salary")&lt;br /&gt;select employee;&lt;br /&gt;foreach (DataRow emp in query)&lt;br /&gt;{&lt;br /&gt;Response.Write(emp.Field&lt;String&gt;("LastName") + ": ");&lt;br /&gt;Response.Write(emp.Field&lt;Decimal&gt;("salary") + "&lt;br /&gt;");&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3931666159715541740?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3931666159715541740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/02/appling-linq-on-adonet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3931666159715541740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3931666159715541740'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/02/appling-linq-on-adonet.html' title='Appling Linq on ADO.net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-4856522464735832310</id><published>2010-02-16T03:39:00.000-08:00</published><updated>2010-02-16T03:40:25.753-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Editable DatagridView linked with database'/><title type='text'>Editable DatagridView linked with database</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Drawing;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using System.Data.OracleClient;&lt;br /&gt;&lt;br /&gt;namespace Trans829115.PL&lt;br /&gt;{&lt;br /&gt;    public partial class frmUpdateDBViaDataGridView : Form&lt;br /&gt;    {&lt;br /&gt;        # region Private variables&lt;br /&gt;&lt;br /&gt;        private OracleConnection objcon;&lt;br /&gt;        private OracleCommand objcmd;&lt;br /&gt;        private OracleDataAdapter objadapter;&lt;br /&gt;        private OracleCommandBuilder objbuilder;&lt;br /&gt;        private DataSet objdataset;&lt;br /&gt;        private DataTable userTable;&lt;br /&gt;        private bool mAllowInsert;&lt;br /&gt;        private bool mAllowDelete;&lt;br /&gt;        private bool IsModifications = false;&lt;br /&gt;        ToolTip errorToolTip = new ToolTip();&lt;br /&gt;               &lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;        public frmUpdateDBViaDataGridView()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // In Form control definition&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;            &lt;br /&gt;            objcon = new OracleConnection(BLL.QuerySet.ConString);&lt;br /&gt;            objcmd= new OracleCommand(BLL.QuerySet.TestQuery, objcon);&lt;br /&gt;            objadapter = new OracleDataAdapter(objcmd);&lt;br /&gt;            objbuilder = new OracleCommandBuilder(objadapter);&lt;br /&gt;            objdataset = new DataSet();&lt;br /&gt;            objadapter.Fill(objdataset);&lt;br /&gt;            userTable = objdataset.Tables[0];&lt;br /&gt;&lt;br /&gt;            userDataGridView.AllowUserToAddRows = true;&lt;br /&gt;            userDataGridView.AllowUserToDeleteRows  = true;&lt;br /&gt;            btnDelete.Enabled = true;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void btnDelete_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            DeleteSelectedData();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void frmUpdateDBViaDataGridView_Load(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            # region datagridveiw events/delegates&lt;br /&gt;&lt;br /&gt;            userDataGridView.CellBeginEdit+=new DataGridViewCellCancelEventHandler(userDataGridView_CellBeginEdit);&lt;br /&gt;            userDataGridView.CellEndEdit+=new DataGridViewCellEventHandler(userDataGridView_CellEndEdit);&lt;br /&gt;            &lt;br /&gt;            userDataGridView.CellValidating+=new DataGridViewCellValidatingEventHandler(userDataGridView_CellValidating);&lt;br /&gt;            userDataGridView.CellValidated+=new DataGridViewCellEventHandler(userDataGridView_CellValidated);&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;            userDataGridView.SelectionChanged+=new EventHandler(userDataGridView_SelectionChanged);&lt;br /&gt;            userDataGridView.CellEnter+=new DataGridViewCellEventHandler(userDataGridView_CellEnter);&lt;br /&gt;            userDataGridView.CellLeave+=new DataGridViewCellEventHandler(userDataGridView_CellLeave);&lt;br /&gt;            &lt;br /&gt;                        &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            #endregion&lt;br /&gt;&lt;br /&gt;            # region custom datagridview settings&lt;br /&gt;&lt;br /&gt;            userDataGridView.MultiSelect = false; &lt;br /&gt;            userDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;&lt;br /&gt;            &lt;br /&gt;            &lt;br /&gt;            #endregion           &lt;br /&gt;            userDataGridView.DataSource = userTable.DefaultView;&lt;br /&gt;            lblRowCount.Text = "Number of records: " + userTable.Rows.Count.ToString();&lt;br /&gt;            userDataGridView.AllowUserToResizeColumns = true;&lt;br /&gt;            if (userTable.Rows.Count == 0)&lt;br /&gt;            {&lt;br /&gt;                btnDelete.Enabled = false;&lt;br /&gt;                btnUpdate.Enabled = false;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void DeleteSelectedData()&lt;br /&gt;        {&lt;br /&gt;            if (MessageBox.Show("Do you really want to delete the selected record(s)?",&lt;br /&gt;                   "Delete records", MessageBoxButtons.YesNo,&lt;br /&gt;                   MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false)&lt;br /&gt;                   == DialogResult.Yes)&lt;br /&gt;            {&lt;br /&gt;                try&lt;br /&gt;                {&lt;br /&gt;                    &lt;br /&gt;                    int cnt = userDataGridView.SelectedRows.Count;&lt;br /&gt;                    for (int i = 0; i &lt; cnt; i++)&lt;br /&gt;                    {&lt;br /&gt;                        if (this.userDataGridView.SelectedRows.Count &gt; 0 &amp;&amp;&lt;br /&gt;                            this.userDataGridView.SelectedRows[0].Index !=&lt;br /&gt;                            this.userDataGridView.Rows.Count - 1)&lt;br /&gt;                        {&lt;br /&gt;                            this.userDataGridView.Rows.RemoveAt(&lt;br /&gt;                               this.userDataGridView.SelectedRows[0].Index);&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if(objdataset.HasChanges())&lt;br /&gt;                    {&lt;br /&gt;                        DataTable changes = objdataset.Tables[0].GetChanges(); &lt;br /&gt;&lt;br /&gt;                if (changes != null) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                objadapter.Update(changes);&lt;br /&gt;                objdataset.Tables[0].AcceptChanges(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                    }&lt;br /&gt;                    &lt;br /&gt;                }&lt;br /&gt;                catch (Exception ex)&lt;br /&gt;                {&lt;br /&gt;                    MessageBox.Show(ex.ToString());&lt;br /&gt;                }&lt;br /&gt;                finally&lt;br /&gt;                {&lt;br /&gt;                    &lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            if (userTable.Rows.Count == 0)&lt;br /&gt;            {&lt;br /&gt;                btnUpdate.Enabled = false;&lt;br /&gt;                if (mAllowDelete) btnDelete.Enabled = false;&lt;br /&gt;            }&lt;br /&gt;            IsModifications = true;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void UpdateModifiedData()&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                objcon.Open();&lt;br /&gt;                objadapter.UpdateCommand = objbuilder.GetUpdateCommand();&lt;br /&gt;                objadapter.Update(userTable);&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show(ex.ToString());&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                objcon.Close();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        private void btnUpdate_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            UpdateModifiedData();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void frmUpdateDBViaDataGridView_FormClosing(object sender, FormClosingEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (IsModifications)&lt;br /&gt;                if (MessageBox.Show("Do you want to save changes?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes)&lt;br /&gt;                    UpdateModifiedData(); &lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void userDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            //if (IsModifications)&lt;br /&gt;            //    if (MessageBox.Show("Do you want to save changes?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes)&lt;br /&gt;            //        UpdateModifiedData(); &lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void userDataGridView_KeyDown(object sender, KeyEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (e.KeyCode == Keys.Delete) DeleteSelectedData();&lt;br /&gt;            e.Handled = true; // Cancel &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #region events&lt;br /&gt;&lt;br /&gt;        public void userDataGridView_SelectionChanged(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            //if(userDataGridView.SelectedRows.Count &gt; 0)&lt;br /&gt;            //{&lt;br /&gt;            //    DataGridViewCellStyle style = new DataGridViewCellStyle();&lt;br /&gt;&lt;br /&gt;            //    style.Font = new Font(userDataGridView.Font, FontStyle.Bold);&lt;br /&gt;&lt;br /&gt;            //    style.ForeColor = System.Drawing.Color.DarkBlue;&lt;br /&gt;&lt;br /&gt;                &lt;br /&gt;            //    userDataGridView.SelectedRows[0].DefaultCellStyle = style;&lt;br /&gt;&lt;br /&gt;            //}&lt;br /&gt;            //else&lt;br /&gt;            //{&lt;br /&gt;            //    // Deformat cells&lt;br /&gt;            //}&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void userDataGridView_CellEnter(object sender, DataGridViewCellEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            //Font underLineFont = new Font(userDataGridView.Font, FontStyle.Underline);&lt;br /&gt;            //userDataGridView[e.ColumnIndex, e.RowIndex].Style.ForeColor = Color.OrangeRed;&lt;br /&gt;            //userDataGridView[e.ColumnIndex, e.RowIndex].Style.Font = underLineFont;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void userDataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            //Font BoldFont = new Font(userDataGridView.Font, FontStyle.Bold); &lt;br /&gt;            //userDataGridView[e.ColumnIndex, e.RowIndex].Style.ForeColor = Color.Black;&lt;br /&gt;            //userDataGridView[e.ColumnIndex, e.RowIndex].Style.Font = BoldFont;&lt;br /&gt;        }&lt;br /&gt;        public void userDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;             if(((DataGridView)sender).CurrentCell.ColumnIndex==1)&lt;br /&gt;             {&lt;br /&gt;                &lt;br /&gt;                 // CurrentCell.EditedFormattedValue is key otherwise currentCell.Value will not work&lt;br /&gt;                 if(((DataGridView)sender).CurrentCell.EditedFormattedValue.ToString().Length &lt; 5)&lt;br /&gt;                 {&lt;br /&gt;                    ((DataGridView)sender).CurrentRow.Cells[0].ErrorText = "Text Length could not be less than five";&lt;br /&gt;                     e.Cancel = true;&lt;br /&gt;                     &lt;br /&gt;                 }&lt;br /&gt;                 else&lt;br /&gt;                 {&lt;br /&gt;                     ((DataGridView)sender).CurrentRow.Cells[0].ErrorText = string.Empty;&lt;br /&gt;                 }&lt;br /&gt;             }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void userDataGridView_CellValidated(object sender, DataGridViewCellEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public void userDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            // restrict column i.e. primary key to get edit&lt;br /&gt;            if(((DataGridView)sender).CurrentCell.ColumnIndex==0)&lt;br /&gt;            {&lt;br /&gt;                e.Cancel = true;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Changing font for the Editing cells&lt;br /&gt;            if(((DataGridView)sender).CurrentCell.ColumnIndex!=0)&lt;br /&gt;            {&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.ForeColor = Color.OrangeRed;&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.Font= new Font("Arial", 10F,FontStyle.Bold);&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.BackColor = Color.LightGray;&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.SelectionForeColor = Color.Yellow;&lt;br /&gt;                          &lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public void userDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)&lt;br /&gt;        {&lt;br /&gt;             // De-formattting the font for the Editing cells&lt;br /&gt;            if(((DataGridView)sender).CurrentCell.ColumnIndex!=0)&lt;br /&gt;            {&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.ForeColor = Color.Black;&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.Font= new Font("Arial", 8F, FontStyle.Bold);&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.BackColor = Color.White;&lt;br /&gt;                ((DataGridView)sender).CurrentCell.Style.SelectionForeColor = Color.DarkBlue;&lt;br /&gt;&lt;br /&gt;                          &lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        #endregion&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-4856522464735832310?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/4856522464735832310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/02/editable-datagridview-linked-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4856522464735832310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4856522464735832310'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/02/editable-datagridview-linked-with.html' title='Editable DatagridView linked with database'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5261433374099682459</id><published>2010-02-08T03:34:00.001-08:00</published><updated>2010-02-08T03:34:58.784-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Convert Text into Title Case/Sentance Case'/><title type='text'>Convert Text into Title Case/Sentance Case</title><content type='html'>public static string ConvertTextIntoSentanceCase(string strValue)&lt;br /&gt;        {&lt;br /&gt;            if(string.IsNullOrEmpty(strValue)) return string.Empty;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            return new System.Globalization.CultureInfo("en").TextInfo.ToTitleCase(strValue.ToLower());&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5261433374099682459?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5261433374099682459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/02/convert-text-into-title-casesentance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5261433374099682459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5261433374099682459'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2010/02/convert-text-into-title-casesentance.html' title='Convert Text into Title Case/Sentance Case'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3563766024942691810</id><published>2009-10-25T23:17:00.001-07:00</published><updated>2009-10-25T23:17:35.753-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Fragment Caching in ASP.NET'/><title type='text'>Fragment Caching in ASP.NET</title><content type='html'>ASP.NET provides a mechanism for caching portions of pages, called page fragment caching. To cache a portion of a page, you must first encapsulate the portion of the page you want to cache into a user control. In the user control source file, add an OutputCache directive specifying the Duration and VaryByParam attributes. When that user control is loaded into a page at runtime, it is cached, and all subsequent pages that reference that same user control will retrieve it from the cache.&lt;br /&gt;&lt;br /&gt;&lt;!— UserControl.ascx —&gt;&lt;br /&gt;&lt;br /&gt;&lt;%@ OutputCache Duration='60'&lt;br /&gt;VaryByParam='none' %&gt;&lt;br /&gt;&lt;%@ Control Language="'C#'" %&gt;&lt;br /&gt;&lt;br /&gt;&lt;script runat="server"&gt;&lt;br /&gt;protected void Page_Load(Object src, EventArgs e)&lt;br /&gt;{&lt;br /&gt;_date.Text = "User control generated at " +&lt;br /&gt;DateTime.Now.ToString();&lt;br /&gt;}&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;&lt;asp:Label id='_date' runat="'server'" /&gt;&lt;br /&gt;&lt;br /&gt;Here I have user caching on user control, so when ever we used in a page , only partial page will be cached.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3563766024942691810?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3563766024942691810/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/10/fragment-caching-in-aspnet.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3563766024942691810'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3563766024942691810'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/10/fragment-caching-in-aspnet.html' title='Fragment Caching in ASP.NET'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2801355095723597990</id><published>2009-10-25T22:07:00.000-07:00</published><updated>2009-10-25T22:08:30.622-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CheckedListBox'/><title type='text'>To get Collection of checked items in  CheckedListBox</title><content type='html'>private void WhatIsChecked_Click(object sender, System.EventArgs e) {&lt;br /&gt;    // Display in a message box all the items that are checked.&lt;br /&gt;&lt;br /&gt;    // First show the index and check state of all selected items.&lt;br /&gt;    foreach(int indexChecked in checkedListBox1.CheckedIndices) {&lt;br /&gt;        // The indexChecked variable contains the index of the item.&lt;br /&gt;        MessageBox.Show("Index#: " + indexChecked.ToString() + ", is checked. Checked state is:" +&lt;br /&gt;                        checkedListBox1.GetItemCheckState(indexChecked).ToString() + ".");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    // Next show the object title and check state for each item selected.&lt;br /&gt;    foreach(object itemChecked in checkedListBox1.CheckedItems) {&lt;br /&gt;&lt;br /&gt;        // Use the IndexOf method to get the index of an item.&lt;br /&gt;        MessageBox.Show("Item with title: \"" + itemChecked.ToString() + &lt;br /&gt;                        "\", is checked. Checked state is: " + &lt;br /&gt;                        checkedListBox1.GetItemCheckState(checkedListBox1.Items.IndexOf(itemChecked)).ToString() + ".");&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2801355095723597990?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2801355095723597990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/10/to-get-collection-of-checked-items-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2801355095723597990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2801355095723597990'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/10/to-get-collection-of-checked-items-in.html' title='To get Collection of checked items in  CheckedListBox'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6297465345503894817</id><published>2009-09-30T03:38:00.000-07:00</published><updated>2009-09-30T03:40:01.151-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='GetDateFormat Method'/><title type='text'>GetDateFormat Method</title><content type='html'>Example: string sdate = dt.GetDateTimeFormats()[3]; // mm/dd/yyyy&lt;br /&gt;&lt;br /&gt;(0) 9/1/2003&lt;br /&gt;(1) 9/1/03&lt;br /&gt;(2) 09/01/03&lt;br /&gt;(3) 09/01/2003&lt;br /&gt;(4) 03/09/01&lt;br /&gt;(5) 2003-09-01&lt;br /&gt;(6) 01-Sep-03&lt;br /&gt;(7) Monday, September 01, 2003&lt;br /&gt;(8) September 01, 2003&lt;br /&gt;(9) Monday, 01 September, 2003&lt;br /&gt;(10) 01 September, 2003&lt;br /&gt;(11) Monday, September 01, 2003 12:00 AM&lt;br /&gt;(12) Monday, September 01, 2003 12:00 AM&lt;br /&gt;(13) Monday, September 01, 2003 0:00&lt;br /&gt;(14) Monday, September 01, 2003 00:00&lt;br /&gt;(15) September 01, 2003 12:00 AM&lt;br /&gt;(16) September 01, 2003 12:00 AM&lt;br /&gt;(17) September 01, 2003 0:00&lt;br /&gt;(18) September 01, 2003 00:00&lt;br /&gt;(19) Monday, 01 September, 2003 12:00 AM&lt;br /&gt;(20) Monday, 01 September, 2003 12:00 AM&lt;br /&gt;(21) Monday, 01 September, 2003 0:00&lt;br /&gt;(22) Monday, 01 September, 2003 00:00&lt;br /&gt;(23) 01 September, 2003 12:00 AM&lt;br /&gt;(24) 01 September, 2003 12:00 AM&lt;br /&gt;(25) 01 September, 2003 0:00&lt;br /&gt;(26) 01 September, 2003 00:00&lt;br /&gt;(27) Monday, September 01, 2003 12:00:00 AM&lt;br /&gt;(28) Monday, September 01, 2003 12:00:00 AM&lt;br /&gt;(29) Monday, September 01, 2003 0:00:00&lt;br /&gt;(30) Monday, September 01, 2003 00:00:00&lt;br /&gt;(31) September 01, 2003 12:00:00 AM&lt;br /&gt;(32) September 01, 2003 12:00:00 AM&lt;br /&gt;(33) September 01, 2003 0:00:00&lt;br /&gt;(34) September 01, 2003 00:00:00&lt;br /&gt;(35) Monday, 01 September, 2003 12:00:00 AM&lt;br /&gt;(36) Monday, 01 September, 2003 12:00:00 AM&lt;br /&gt;(37) Monday, 01 September, 2003 0:00:00&lt;br /&gt;(38) Monday, 01 September, 2003 00:00:00&lt;br /&gt;(39) 01 September, 2003 12:00:00 AM&lt;br /&gt;(40) 01 September, 2003 12:00:00 AM&lt;br /&gt;(41) 01 September, 2003 0:00:00&lt;br /&gt;(42) 01 September, 2003 00:00:00&lt;br /&gt;(43) 9/1/2003 12:00 AM&lt;br /&gt;(44) 9/1/2003 12:00 AM&lt;br /&gt;(45) 9/1/2003 0:00&lt;br /&gt;(46) 9/1/2003 00:00&lt;br /&gt;(47) 9/1/03 12:00 AM&lt;br /&gt;(48) 9/1/03 12:00 AM&lt;br /&gt;(49) 9/1/03 0:00&lt;br /&gt;(50) 9/1/03 00:00&lt;br /&gt;(51) 09/01/03 12:00 AM&lt;br /&gt;(52) 09/01/03 12:00 AM&lt;br /&gt;(53) 09/01/03 0:00&lt;br /&gt;(54) 09/01/03 00:00&lt;br /&gt;(55) 09/01/2003 12:00 AM&lt;br /&gt;(56) 09/01/2003 12:00 AM&lt;br /&gt;(57) 09/01/2003 0:00&lt;br /&gt;(58) 09/01/2003 00:00&lt;br /&gt;(59) 03/09/01 12:00 AM&lt;br /&gt;(60) 03/09/01 12:00 AM&lt;br /&gt;(61) 03/09/01 0:00&lt;br /&gt;(62) 03/09/01 00:00&lt;br /&gt;(63) 2003-09-01 12:00 AM&lt;br /&gt;(64) 2003-09-01 12:00 AM&lt;br /&gt;(65) 2003-09-01 0:00&lt;br /&gt;(66) 2003-09-01 00:00&lt;br /&gt;(67) 01-Sep-03 12:00 AM&lt;br /&gt;(68) 01-Sep-03 12:00 AM&lt;br /&gt;(69) 01-Sep-03 0:00&lt;br /&gt;(70) 01-Sep-03 00:00&lt;br /&gt;(71) 9/1/2003 12:00:00 AM&lt;br /&gt;(72) 9/1/2003 12:00:00 AM&lt;br /&gt;(73) 9/1/2003 0:00:00&lt;br /&gt;(74) 9/1/2003 00:00:00&lt;br /&gt;(75) 9/1/03 12:00:00 AM&lt;br /&gt;(76) 9/1/03 12:00:00 AM&lt;br /&gt;(77) 9/1/03 0:00:00&lt;br /&gt;(78) 9/1/03 00:00:00&lt;br /&gt;(79) 09/01/03 12:00:00 AM&lt;br /&gt;(80) 09/01/03 12:00:00 AM&lt;br /&gt;(81) 09/01/03 0:00:00&lt;br /&gt;(82) 09/01/03 00:00:00&lt;br /&gt;(83) 09/01/2003 12:00:00 AM&lt;br /&gt;(84) 09/01/2003 12:00:00 AM&lt;br /&gt;(85) 09/01/2003 0:00:00&lt;br /&gt;(86) 09/01/2003 00:00:00&lt;br /&gt;(87) 03/09/01 12:00:00 AM&lt;br /&gt;(88) 03/09/01 12:00:00 AM&lt;br /&gt;(89) 03/09/01 0:00:00&lt;br /&gt;(90) 03/09/01 00:00:00&lt;br /&gt;(91) 2003-09-01 12:00:00 AM&lt;br /&gt;(92) 2003-09-01 12:00:00 AM&lt;br /&gt;(93) 2003-09-01 0:00:00&lt;br /&gt;(94) 2003-09-01 00:00:00&lt;br /&gt;(95) 01-Sep-03 12:00:00 AM&lt;br /&gt;(96) 01-Sep-03 12:00:00 AM&lt;br /&gt;(97) 01-Sep-03 0:00:00&lt;br /&gt;(98) 01-Sep-03 00:00:00&lt;br /&gt;(99) September 01&lt;br /&gt;(100) September 01&lt;br /&gt;(101) Mon, 01 Sep 2003 00:00:00 GMT&lt;br /&gt;(102) Mon, 01 Sep 2003 00:00:00 GMT&lt;br /&gt;(103) 2003-09-01T00:00:00&lt;br /&gt;(104) 12:00 AM&lt;br /&gt;(105) 12:00 AM&lt;br /&gt;(106) 0:00&lt;br /&gt;(107) 00:00&lt;br /&gt;(108) 12:00:00 AM&lt;br /&gt;(109) 12:00:00 AM&lt;br /&gt;(110) 0:00:00&lt;br /&gt;(111) 00:00:00&lt;br /&gt;(112) 2003-09-01 00:00:00Z&lt;br /&gt;(113) Monday, September 01, 2003 4:00:00 AM&lt;br /&gt;(114) Monday, September 01, 2003 04:00:00 AM&lt;br /&gt;(115) Monday, September 01, 2003 4:00:00&lt;br /&gt;(116) Monday, September 01, 2003 04:00:00&lt;br /&gt;(117) September 01, 2003 4:00:00 AM&lt;br /&gt;(118) September 01, 2003 04:00:00 AM&lt;br /&gt;(119) September 01, 2003 4:00:00&lt;br /&gt;(120) September 01, 2003 04:00:00&lt;br /&gt;(121) Monday, 01 September, 2003 4:00:00 AM&lt;br /&gt;(122) Monday, 01 September, 2003 04:00:00 AM&lt;br /&gt;(123) Monday, 01 September, 2003 4:00:00&lt;br /&gt;(124) Monday, 01 September, 2003 04:00:00&lt;br /&gt;(125) 01 September, 2003 4:00:00 AM&lt;br /&gt;(126) 01 September, 2003 04:00:00 AM&lt;br /&gt;(127) 01 September, 2003 4:00:00&lt;br /&gt;(128) 01 September, 2003 04:00:00&lt;br /&gt;(129) September, 2003&lt;br /&gt;(130) September, 2003&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Here are the results of en-GB - (english, Great Britain) formats:&lt;br /&gt;&lt;br /&gt;(0) 01/09/2003&lt;br /&gt;(1) 01/09/03&lt;br /&gt;(2) 1/9/03&lt;br /&gt;(3) 1.9.03&lt;br /&gt;(4) 2003-09-01&lt;br /&gt;(5) 01 September 2003&lt;br /&gt;(6) 1 September 2003&lt;br /&gt;(7) 01 September 2003 00:00&lt;br /&gt;(8) 01 September 2003 0:00&lt;br /&gt;(9) 01 September 2003 12:00 AM&lt;br /&gt;(10) 01 September 2003 12:00 AM&lt;br /&gt;(11) 1 September 2003 00:00&lt;br /&gt;(12) 1 September 2003 0:00&lt;br /&gt;(13) 1 September 2003 12:00 AM&lt;br /&gt;(14) 1 September 2003 12:00 AM&lt;br /&gt;(15) 01 September 2003 00:00:00&lt;br /&gt;(16) 01 September 2003 0:00:00&lt;br /&gt;(17) 01 September 2003 12:00:00 AM&lt;br /&gt;(18) 01 September 2003 12:00:00 AM&lt;br /&gt;(19) 1 September 2003 00:00:00&lt;br /&gt;(20) 1 September 2003 0:00:00&lt;br /&gt;(21) 1 September 2003 12:00:00 AM&lt;br /&gt;(22) 1 September 2003 12:00:00 AM&lt;br /&gt;(23) 01/09/2003 00:00&lt;br /&gt;(24) 01/09/2003 0:00&lt;br /&gt;(25) 01/09/2003 12:00 AM&lt;br /&gt;(26) 01/09/2003 12:00 AM&lt;br /&gt;(27) 01/09/03 00:00&lt;br /&gt;(28) 01/09/03 0:00&lt;br /&gt;(29) 01/09/03 12:00 AM&lt;br /&gt;(30) 01/09/03 12:00 AM&lt;br /&gt;(31) 1/9/03 00:00&lt;br /&gt;(32) 1/9/03 0:00&lt;br /&gt;(33) 1/9/03 12:00 AM&lt;br /&gt;(34) 1/9/03 12:00 AM&lt;br /&gt;(35) 1.9.03 00:00&lt;br /&gt;(36) 1.9.03 0:00&lt;br /&gt;(37) 1.9.03 12:00 AM&lt;br /&gt;(38) 1.9.03 12:00 AM&lt;br /&gt;(39) 2003-09-01 00:00&lt;br /&gt;(40) 2003-09-01 0:00&lt;br /&gt;(41) 2003-09-01 12:00 AM&lt;br /&gt;(42) 2003-09-01 12:00 AM&lt;br /&gt;(43) 01/09/2003 00:00:00&lt;br /&gt;(44) 01/09/2003 0:00:00&lt;br /&gt;(45) 01/09/2003 12:00:00 AM&lt;br /&gt;(46) 01/09/2003 12:00:00 AM&lt;br /&gt;(47) 01/09/03 00:00:00&lt;br /&gt;(48) 01/09/03 0:00:00&lt;br /&gt;(49) 01/09/03 12:00:00 AM&lt;br /&gt;(50) 01/09/03 12:00:00 AM&lt;br /&gt;(51) 1/9/03 00:00:00&lt;br /&gt;(52) 1/9/03 0:00:00&lt;br /&gt;(53) 1/9/03 12:00:00 AM&lt;br /&gt;(54) 1/9/03 12:00:00 AM&lt;br /&gt;(55) 1.9.03 00:00:00&lt;br /&gt;(56) 1.9.03 0:00:00&lt;br /&gt;(57) 1.9.03 12:00:00 AM&lt;br /&gt;(58) 1.9.03 12:00:00 AM&lt;br /&gt;(59) 2003-09-01 00:00:00&lt;br /&gt;(60) 2003-09-01 0:00:00&lt;br /&gt;(61) 2003-09-01 12:00:00 AM&lt;br /&gt;(62) 2003-09-01 12:00:00 AM&lt;br /&gt;(63) 01 September&lt;br /&gt;(64) 01 September&lt;br /&gt;(65) Mon, 01 Sep 2003 00:00:00 GMT&lt;br /&gt;(66) Mon, 01 Sep 2003 00:00:00 GMT&lt;br /&gt;(67) 2003-09-01T00:00:00&lt;br /&gt;(68) 00:00&lt;br /&gt;(69) 0:00&lt;br /&gt;(70) 12:00 AM&lt;br /&gt;(71) 12:00 AM&lt;br /&gt;(72) 00:00:00&lt;br /&gt;(73) 0:00:00&lt;br /&gt;(74) 12:00:00 AM&lt;br /&gt;(75) 12:00:00 AM&lt;br /&gt;(76) 2003-09-01 00:00:00Z&lt;br /&gt;(77) 01 September 2003 04:00:00&lt;br /&gt;(78) 01 September 2003 4:00:00&lt;br /&gt;(79) 01 September 2003 04:00:00 AM&lt;br /&gt;(80) 01 September 2003 4:00:00 AM&lt;br /&gt;(81) 1 September 2003 04:00:00&lt;br /&gt;(82) 1 September 2003 4:00:00&lt;br /&gt;(83) 1 September 2003 04:00:00 AM&lt;br /&gt;(84) 1 September 2003 4:00:00 AM&lt;br /&gt;(85) September 2003&lt;br /&gt;(86) September 2003&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6297465345503894817?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6297465345503894817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/09/getdateformat-method.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6297465345503894817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6297465345503894817'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/09/getdateformat-method.html' title='GetDateFormat Method'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6153568469980871663</id><published>2009-09-10T04:55:00.000-07:00</published><updated>2009-09-10T04:57:03.538-07:00</updated><title type='text'>Iterate through SeverVariable in ASP.net</title><content type='html'>public string ServerVariables()&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        System.Collections.Specialized.NameValueCollection oValues =&lt;br /&gt;            new System.Collections.Specialized.NameValueCollection();&lt;br /&gt;        oValues = Request.ServerVariables;&lt;br /&gt;        for(int i=0; i &lt; oValues.Count ; i++)&lt;br /&gt;        {&lt;br /&gt;            value += string.Format("Key {0} - Text {1}", oValues.Keys[i].ToString(), oValues.Get(i).ToString());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        return value;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6153568469980871663?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6153568469980871663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/09/iterate-through-severvariable-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6153568469980871663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6153568469980871663'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/09/iterate-through-severvariable-in-aspnet.html' title='Iterate through SeverVariable in ASP.net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6177461051543176985</id><published>2009-06-30T23:03:00.001-07:00</published><updated>2009-06-30T23:04:04.033-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System.IO'/><title type='text'>Combine byte[]</title><content type='html'>public byte[] CombineArrays(byte[] a, byte[] b)&lt;br /&gt;        {&lt;br /&gt;           byte[] c = new byte[a.Length + b.Length]; &lt;br /&gt;           System.Buffer.BlockCopy(a, 0, c, 0, a.Length); &lt;br /&gt;           System.Buffer.BlockCopy(b, 0, c, a.Length, b.Length); &lt;br /&gt;           return c; &lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6177461051543176985?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6177461051543176985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/string-to-byte_30.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6177461051543176985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6177461051543176985'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/string-to-byte_30.html' title='Combine byte[]'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-7747230393160869843</id><published>2009-06-30T22:59:00.000-07:00</published><updated>2009-06-30T23:01:06.351-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System.IO'/><title type='text'>Write text file from the byte[]</title><content type='html'>public static void WriteFileStreamFromArray(string FilePath, byte[] b)&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;                      &lt;br /&gt;            FileStream fs = null;&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;            &lt;br /&gt;             fs = new  FileStream(FilePath,FileMode.Append);&lt;br /&gt;            &lt;br /&gt;             fs.Write(b, 0, b.Length);&lt;br /&gt;             &lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;            fs.Close();&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-7747230393160869843?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/7747230393160869843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/combine-two-byte-into-one-byte.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7747230393160869843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/7747230393160869843'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/combine-two-byte-into-one-byte.html' title='Write text file from the byte[]'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3446744137775937449</id><published>2009-06-30T22:57:00.000-07:00</published><updated>2009-06-30T22:58:55.125-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System.IO'/><title type='text'>Convert byte [] to string</title><content type='html'>public string convertByteArrayToString(byte[] input)&lt;br /&gt;        {&lt;br /&gt;        System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();&lt;br /&gt;        string str = enc.GetString(input);&lt;br /&gt;        return str;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3446744137775937449?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3446744137775937449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/string-to-byte.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3446744137775937449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3446744137775937449'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/string-to-byte.html' title='Convert byte [] to string'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3890905784733675687</id><published>2009-06-30T22:56:00.000-07:00</published><updated>2009-06-30T22:57:27.612-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System.IO'/><title type='text'>Get Bytes [] from the File</title><content type='html'>public byte[] GetBytesFromFile(string fullFilePath)&lt;br /&gt;        {&lt;br /&gt;         // this method is limited to 2^32 byte files (4.2 GB)&lt;br /&gt;&lt;br /&gt;         FileStream fs = File.OpenRead(fullFilePath);&lt;br /&gt;         try&lt;br /&gt;         {&lt;br /&gt;          byte[] bytes = new byte[fs.Length];&lt;br /&gt;          fs.Read(bytes, 0, Convert.ToInt32(fs.Length));&lt;br /&gt;          fs.Close();&lt;br /&gt;          return bytes;&lt;br /&gt;         }&lt;br /&gt;         finally&lt;br /&gt;         {&lt;br /&gt;          fs.Close();&lt;br /&gt;         }&lt;br /&gt;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3890905784733675687?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3890905784733675687/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/get-bytes-from-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3890905784733675687'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3890905784733675687'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/get-bytes-from-file.html' title='Get Bytes [] from the File'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8788386636572527751</id><published>2009-06-30T22:55:00.000-07:00</published><updated>2009-06-30T22:56:20.366-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='System.IO'/><title type='text'>Read whole text of text file into string</title><content type='html'>public string mReadFileIntoString(string FullPath, string Separator)&lt;br /&gt;        {&lt;br /&gt;            string ReturnString = string.Empty;&lt;br /&gt;&lt;br /&gt;            if (!string.IsNullOrEmpty(FullPath) &amp;&amp; !string.IsNullOrEmpty(Separator))&lt;br /&gt;            {&lt;br /&gt;                if (File.Exists(FullPath))&lt;br /&gt;                {&lt;br /&gt;                    try&lt;br /&gt;                    {&lt;br /&gt;                        string Line = string.Empty;&lt;br /&gt;&lt;br /&gt;                        using (FileStream fs = new FileStream(FullPath, FileMode.Open, FileAccess.Read))&lt;br /&gt;                        {&lt;br /&gt;                            using (StreamReader rd = new StreamReader(fs, Encoding.Default))&lt;br /&gt;                            {&lt;br /&gt;                                while (!rd.EndOfStream)&lt;br /&gt;                                {&lt;br /&gt;                                    Line = rd.ReadLine();&lt;br /&gt;                                    if (string.IsNullOrEmpty(ReturnString) &amp;&amp; !string.IsNullOrEmpty(Line))&lt;br /&gt;                                        ReturnString = Line;&lt;br /&gt;                                    else if (!string.IsNullOrEmpty(ReturnString) &amp;&amp; !string.IsNullOrEmpty(Line))&lt;br /&gt;                                        ReturnString = ReturnString + Separator + Line;&lt;br /&gt;                                }&lt;br /&gt;                                rd.Close();&lt;br /&gt;                            }&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                        return ReturnString;&lt;br /&gt;                    }&lt;br /&gt;                    catch (Exception ex)&lt;br /&gt;                    {&lt;br /&gt;                        System.Windows.Forms.MessageBox.Show("{0} has Input Error, Please Check the Input Files", FullPath);&lt;br /&gt;                        System.Windows.Forms.MessageBox.Show("Please re-run the application with correct Input");&lt;br /&gt;                        return string.Empty;&lt;br /&gt;                        // return string.Format("{0} has Input Error, Please Check the Input Files", FullPath);&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;                else&lt;br /&gt;                {&lt;br /&gt;                    System.Windows.Forms.MessageBox.Show("{0} does not Exists, Please Check the Input Files", FullPath);&lt;br /&gt;                    System.Windows.Forms.MessageBox.Show("Please re-run the application with correct Input");&lt;br /&gt;                    return string.Empty;&lt;br /&gt;                    // return string.Format("{0} does not Exists, Please Check the Input Files", FullPath);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            return null;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8788386636572527751?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8788386636572527751/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/read-whole-text-of-text-file-into.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8788386636572527751'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8788386636572527751'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/read-whole-text-of-text-file-into.html' title='Read whole text of text file into string'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-449117132540904889</id><published>2009-06-26T21:37:00.001-07:00</published><updated>2009-06-26T21:37:59.162-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sending Email'/><title type='text'>Sending Email Via SMTP mail Server</title><content type='html'>To send emails your SmtpServer should be running. This can be checked using the Internet Services Manager found in Start-&gt;Programs-&gt;Administrative Tools. When you open the Internet Services Manager you can see whether the Default SMTP Virtual Server is running or not. If the ‘Play’ icon in the toolbar is disabled it means that the Default SMTP Virtual Server is running. You can also check by Right clicking the Default SMTP Virtual Server and see whether ‘Start’ is disabled. If it is so then the Default SMTP Virtual Server is running. This SMTP Service is shipped with Windows XP Professional and Windows 2000 by default.&lt;br /&gt;&lt;br /&gt;It is better to test your SMTP Server whether it functions properly before developing any application in ASP.Net to send emails. The easiest way to test the SMTP Server is to open a text editor like Notepad and write,&lt;br /&gt;&lt;br /&gt;To: someperson@somesite.com&lt;br /&gt;From: me@mysite.com&lt;br /&gt;Subject: Testing SMTP Server in my system.&lt;br /&gt;&lt;br /&gt;Make sure that you are typing some valid email address for the To and From fields in the text file. Now save this text file in c:\inetpub\mailroot\pickup folder. Once you save this file it will disappear indicating that the mail has been sent. If the SMTP Server is not functioning properly it will not disappear indicating that the mail is not sent. The SMTP Service uses the c:\inetpub\mailroot folder for all the mail services.&lt;br /&gt;&lt;br /&gt;Now we will see how to send mails from your web application. Create a web application using your Visual Studio.Net IDE. Now drop four text fields in the design page and make the fourth field to accept multi-line content by setting the TextMode property to MultiLine. Drop down a submit button which can be used to send mails when clicked. Now double click the button on the form to open the code window and write code in the Button1_Click() event to send emails. The steps involved in code are:&lt;br /&gt;&lt;br /&gt;1. Import the System.Web.Mail namespace&lt;br /&gt;2. Create an instance of the MailMessage class&lt;br /&gt;3. Set the properties of the MailMessage class like To, From, Subject, and Body&lt;br /&gt;4. Use the Send method of the SmtpMail class to send the email message by passing the instance of the MailMessage class as the parameter to the Send method.&lt;br /&gt;&lt;br /&gt;The code for sending emails will look somewhat like this after you follow the above steps:&lt;br /&gt;&lt;br /&gt;using System.Web.Mail; &lt;br /&gt;&lt;br /&gt;protected MailMessage emailMesg;&lt;br /&gt;&lt;br /&gt;emailMesg = new MailMessage();&lt;br /&gt;emailMesg.From = txtFrom.Text;&lt;br /&gt;emailMesg.To = txtTo.Text;&lt;br /&gt;emailMesg.Subject = txtSubject.Text;&lt;br /&gt;emailMesg.Body = txtBody.Text;&lt;br /&gt;emailMesg.Priority = MailPriority.High;&lt;br /&gt;SmtpMail.Send(emailMesg);&lt;br /&gt;By default the mail messages are sent as Plain text. It is possible to send mails in the HTML format which allows you to sent mails as web pages which is rich in look. To send emails in the HTML format you need to set the BodyFormat property of the MailMessage instance to MailFormat.Html. If you need to send mail in HTML format the above code would be added one more line like,&lt;br /&gt;&lt;br /&gt;emailMesg.BodyFormat = MailFormat.Html;&lt;br /&gt;&lt;br /&gt;The Body property of the MailMessage instance would be in the HTML code as given in the following example.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The above HTML code will send the mail message in white color with Maroon background color for the page. You can also send attachments with an email message. For sending attachments you have to use the MailAttachment class available. The code given below will add a file as attachment to the email message.&lt;br /&gt;&lt;br /&gt;protected MailAttachment emailAttach;&lt;br /&gt;emailAttach = new MailAttachment(@"path-to-the-document");&lt;br /&gt;emailMesg.Attachments.Add(emailAttach)&lt;br /&gt;&lt;br /&gt;This code has to be given before using the Send method. The path to the document to be attached can also be given from the File Input field in the HTML code.&lt;br /&gt;&lt;br /&gt;Thus it is easy to send emails through a web page in your web application. You may try to send emails by following the above methods in your websites&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-449117132540904889?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/449117132540904889/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/sending-email-via-smtp-mail-server.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/449117132540904889'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/449117132540904889'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/sending-email-via-smtp-mail-server.html' title='Sending Email Via SMTP mail Server'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5557258434207802763</id><published>2009-06-19T22:23:00.001-07:00</published><updated>2009-06-19T22:23:57.846-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Write CSV from DataReader'/><title type='text'>Write CSV from Oralce Reader</title><content type='html'>public static string mWriteRequired(OracleDataReader rd)&lt;br /&gt;        {&lt;br /&gt;            StringBuilder sb = new StringBuilder();&lt;br /&gt;            //For field Names&lt;br /&gt;            for(int i = 0 ;i&lt; rd.FieldCount;i++)&lt;br /&gt;            {&lt;br /&gt;            if( i &lt; (rd.FieldCount - 1) )&lt;br /&gt;            {&lt;br /&gt;            sb.Append("\t" + rd.GetName(i) + "\t" + ",");&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;            sb.Append("\t" + rd.GetName(i) + "\t" + "\n");&lt;br /&gt;            }&lt;br /&gt;            }&lt;br /&gt;            //For field Values&lt;br /&gt;            while( rd.Read())&lt;br /&gt;            {&lt;br /&gt;            for(int i = 0 ;i&lt; rd.FieldCount;i++)&lt;br /&gt;            {&lt;br /&gt;            if( i &lt; (rd.FieldCount - 1) )&lt;br /&gt;            {&lt;br /&gt;            sb.Append("\t" + rd.GetValue(i) + "\t" + ",");&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;            sb.Append("\t" + rd.GetValue(i) + "\t" + "\n");&lt;br /&gt;            }&lt;br /&gt;            }&lt;br /&gt;            }&lt;br /&gt;            rd.Close();&lt;br /&gt;            return sb.ToString();&lt;br /&gt;            &lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5557258434207802763?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5557258434207802763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/write-csv-from-oralce-reader.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5557258434207802763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5557258434207802763'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/write-csv-from-oralce-reader.html' title='Write CSV from Oralce Reader'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8189290441139170661</id><published>2009-06-08T22:12:00.000-07:00</published><updated>2009-06-08T22:17:44.070-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>How to display Client Date and Time</title><content type='html'>function displayTime()&lt;br /&gt;    {&lt;br /&gt;        var localTime = new Date();&lt;br /&gt;        var year= localTime.getYear();&lt;br /&gt;        var month= localTime.getMonth() +1;&lt;br /&gt;        var date = localTime.getDate();&lt;br /&gt;        var hours = localTime .getHours();&lt;br /&gt;        var minutes = localTime .getMinutes();&lt;br /&gt;        var seconds = localTime .getSeconds();    &lt;br /&gt;        var div=document.getElementById("div1");&lt;br /&gt;        div.innerText=year+"-"+month+"-"+date+" "+hours+":"+minutes+":"+seconds;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8189290441139170661?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8189290441139170661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/how-to-display-client-date-and-time.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8189290441139170661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8189290441139170661'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/06/how-to-display-client-date-and-time.html' title='How to display Client Date and Time'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-1980345229532247791</id><published>2009-05-28T22:00:00.001-07:00</published><updated>2009-05-28T22:00:51.006-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>Get Network Information in C#</title><content type='html'>public static string DisplayNICInfo()&lt;br /&gt;            {&lt;br /&gt;                 //Display current network adapter states&lt;br /&gt;                StringBuilder sb= new StringBuilder();&lt;br /&gt;                NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();&lt;br /&gt;                sb.Append("Network Adapter Information:");&lt;br /&gt;                foreach (NetworkInterface n in adapters)&lt;br /&gt;                {&lt;br /&gt;                    sb.Append(string.Format("\tId: {0}", n.Id));&lt;br /&gt;                    sb.Append(string.Format("\tPhysical (MAC) Address: {0}",&lt;br /&gt;                        n.GetPhysicalAddress().ToString()));&lt;br /&gt;                    sb.Append(string.Format("\tDescription: {0}", n.Description));&lt;br /&gt;                    sb.Append(string.Format("\tName: {0}", n.Name));&lt;br /&gt;                    sb.Append(string.Format("\tOperationalStatus: {0}",&lt;br /&gt;                            n.OperationalStatus.ToString()));&lt;br /&gt;                    sb.Append(string.Format("\tInterface type: {0}",&lt;br /&gt;                            n.NetworkInterfaceType.ToString()));&lt;br /&gt;                    sb.Append(string.Format("\tSpeed: {0}", n.Speed));&lt;br /&gt;                    //IPInterfaceProperties ipProps = n.GetIPProperties();&lt;br /&gt;                    //DisplayInterfaceProperties(ipProps);&lt;br /&gt;                }&lt;br /&gt;                return sb.ToString();&lt;br /&gt;            }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-1980345229532247791?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/1980345229532247791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/get-network-information-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1980345229532247791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1980345229532247791'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/get-network-information-in-c.html' title='Get Network Information in C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-4111919155200874895</id><published>2009-05-28T03:21:00.001-07:00</published><updated>2009-05-28T03:21:55.333-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Simplest way to send email using GMail in ASP.Net (C#)</title><content type='html'>/// &lt;summary&gt;&lt;br /&gt;    /// This is the primery method try from the program&lt;br /&gt;    /// Latest &amp; easiest method of sending an Email using ASP.NET&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    /// &lt;param name="to"&gt;&lt;/param&gt;&lt;br /&gt;    /// &lt;param name="from"&gt;&lt;/param&gt;&lt;br /&gt;    /// &lt;param name="subject"&gt;&lt;/param&gt;&lt;br /&gt;    /// &lt;param name="body"&gt;&lt;/param&gt;&lt;br /&gt;    public static void sendMail(string to, string from, string subject, string body)&lt;br /&gt;    {&lt;br /&gt;        ///Smtp config&lt;br /&gt;        SmtpClient client = new SmtpClient("smtp.gmail.com", 465);&lt;br /&gt;  // Edit password and username&lt;br /&gt;        client.Credentials = new NetworkCredential("kalit.sikka@gmail.com", "password");&lt;br /&gt;        client.EnableSsl = true;&lt;br /&gt;&lt;br /&gt;        ///mail details&lt;br /&gt;        MailMessage msg = new MailMessage();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            msg.From = new MailAddress(from);&lt;br /&gt;            msg.To.Add(to);&lt;br /&gt;            // msg.SubjectEncoding = System.Text.Encoding.UTF8;&lt;br /&gt;            msg.Subject = subject;&lt;br /&gt;            //msg.CC.Add();&lt;br /&gt;            msg.IsBodyHtml = true;&lt;br /&gt;            msg.BodyEncoding = System.Text.Encoding.UTF8;&lt;br /&gt;            msg.Body = body;&lt;br /&gt;            msg.Priority = MailPriority.Normal;&lt;br /&gt;            &lt;br /&gt;            // Enable one of the following method.&lt;br /&gt;&lt;br /&gt;            client.Send(msg);&lt;br /&gt;&lt;br /&gt;            // or use the following alternative after enabling send mail asynchronous option in the global.asax &lt;br /&gt;&lt;br /&gt;            //object userState = msg;&lt;br /&gt;            //client.SendAsync(msg, userState);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;        catch (Exception exp)&lt;br /&gt;        {&lt;br /&gt;            ///This runs the backup plan&lt;br /&gt;            SendMailAlt(to, from, subject, body);&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-4111919155200874895?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/4111919155200874895/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/simplest-way-to-send-email-using-gmail.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4111919155200874895'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4111919155200874895'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/simplest-way-to-send-email-using-gmail.html' title='Simplest way to send email using GMail in ASP.Net (C#)'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-379633006872294952</id><published>2009-05-25T00:23:00.000-07:00</published><updated>2009-05-25T00:24:54.255-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='ADO.Net'/><title type='text'>Write TextFile from SQLDataReader</title><content type='html'>public static void mWriteTextFileFromSQLDataReader(SqlDataReader rd, string strTextFilePath)&lt;br /&gt;        {&lt;br /&gt;            using (FileStream fs = new FileStream(strTextFilePath, FileMode.Create, FileAccess.Write))&lt;br /&gt;            {&lt;br /&gt;                using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Unicode))&lt;br /&gt;                {&lt;br /&gt;                    while (rd.Read())&lt;br /&gt;                    {&lt;br /&gt;                        &lt;br /&gt;                        for (int i = 0; i &lt; rd.VisibleFieldCount; i++)&lt;br /&gt;                        {&lt;br /&gt;                            if (!rd.IsDBNull(i))&lt;br /&gt;                            {&lt;br /&gt;                                switch (rd.GetDataTypeName(i))&lt;br /&gt;                                {&lt;br /&gt;                                    case "NUMBER":&lt;br /&gt;                                        sw.Write(rd.GetInt32(i).ToString());&lt;br /&gt;                                        break;&lt;br /&gt;                                    case "DATE":&lt;br /&gt;                                        sw.Write(rd.GetDateTime(i).ToString("MM/dd/yyyy HH:mm:ss"));&lt;br /&gt;                                        break;&lt;br /&gt;                                    case "VARCHAR2":&lt;br /&gt;                                        sw.Write(rd.GetString(i));&lt;br /&gt;                                        break;&lt;br /&gt;                                    default:&lt;br /&gt;                                        sw.WriteLine(rd.GetValue(i).ToString());&lt;br /&gt;                                        break;&lt;br /&gt;                                }&lt;br /&gt;&lt;br /&gt;                                if (i &lt; rd.VisibleFieldCount) // Between DataFields&lt;br /&gt;                                    sw.Write("\t");&lt;br /&gt;                                &lt;br /&gt;                               &lt;br /&gt;                            }&lt;br /&gt;                        }&lt;br /&gt;&lt;br /&gt;                        sw.WriteLine();  // Between Records&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-379633006872294952?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/379633006872294952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/write-textfile-from-sqldatareader.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/379633006872294952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/379633006872294952'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/write-textfile-from-sqldatareader.html' title='Write TextFile from SQLDataReader'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-744033167229357269</id><published>2009-05-20T02:59:00.000-07:00</published><updated>2009-05-20T03:01:05.585-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WinForms'/><category scheme='http://www.blogger.com/atom/ns#' term='.Net'/><title type='text'>Disable Editing in DataGridView+Winforms</title><content type='html'>// Method 1&lt;br /&gt;&lt;br /&gt;private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)&lt;br /&gt;{&lt;br /&gt;         if (((DataGridView)sender).CurrentCell.ColumnIndex == 1)&lt;br /&gt;         e.Cancel = true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//Method 2&lt;br /&gt;&lt;br /&gt;private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)&lt;br /&gt;{&lt;br /&gt;         if(this.dataGridView1.CurrentCell.ColumnIndex==1)&lt;br /&gt;         this.dataGridView1.CurrentCell.Selected = false;&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-744033167229357269?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/744033167229357269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/disable-editing-in-datagridviewwinforms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/744033167229357269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/744033167229357269'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/disable-editing-in-datagridviewwinforms.html' title='Disable Editing in DataGridView+Winforms'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-4956918365224477133</id><published>2009-05-19T23:46:00.000-07:00</published><updated>2009-05-19T23:49:00.200-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ADO.Net'/><title type='text'>Export DataTable into CSV</title><content type='html'>class ExportDataToCSV&lt;br /&gt;    {&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;    /// It will export data in DataTable into CSV format&lt;br /&gt;    /// and use TextWriter Object to write it.&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;    /// &lt;param name="dt"&gt;&lt;/param&gt;&lt;br /&gt;    /// &lt;param name="httpStream"&gt;&lt;/param&gt;&lt;br /&gt;    /// &lt;param name="WriteHeader"&gt;&lt;/param&gt;&lt;br /&gt;    public static void mCreateCSV(DataTable dt, System.IO.TextWriter httpStream, bool WriteHeader)&lt;br /&gt;	{&lt;br /&gt;		if(WriteHeader)&lt;br /&gt;		{&lt;br /&gt;			string[] arr = new String[dt.Columns.Count];&lt;br /&gt;                        int k = dt.Columns.Count;&lt;br /&gt;			for(int i = 0; i&lt;k; i++)&lt;br /&gt;			{&lt;br /&gt;				arr[i] = dt.Columns[i].ColumnName;&lt;br /&gt;				arr[i] = GetWriteableValue(arr[i]);&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			httpStream.WriteLine(string.Join(",", arr));&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		for(int j = 0; j&lt;dt.Rows.Count; j++)&lt;br /&gt;		{&lt;br /&gt;			string[] dataArr = new String[dt.Columns.Count];&lt;br /&gt;			for(int i = 0; i&lt;dt.Columns.Count; i++)&lt;br /&gt;			{&lt;br /&gt;				object o = dt.Rows[j][i];&lt;br /&gt;				dataArr[i] = GetWriteableValue(o);&lt;br /&gt;			}&lt;br /&gt;			httpStream.WriteLine(string.Join(",", dataArr));&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	/// &lt;summary&gt;&lt;br /&gt;	/// It will export Data in DataTable into CSV format&lt;br /&gt;    /// and write it using object of StreamWriter&lt;br /&gt;	/// &lt;/summary&gt;&lt;br /&gt;	/// &lt;param name="dt"&gt;&lt;/param&gt;&lt;br /&gt;	/// &lt;param name="file"&gt;&lt;/param&gt;&lt;br /&gt;	/// &lt;param name="WriteHeader"&gt;&lt;/param&gt;&lt;br /&gt;	public static void mCreateCSV(DataTable dt, System.IO.StreamWriter file, bool WriteHeader)&lt;br /&gt;	{&lt;br /&gt;		if(WriteHeader)&lt;br /&gt;		{&lt;br /&gt;			string[] arr = new String[dt.Columns.Count];&lt;br /&gt;			for(int i = 0; i&lt;dt.Columns.Count; i++)&lt;br /&gt;			{&lt;br /&gt;				arr[i] = dt.Columns[i].ColumnName;&lt;br /&gt;				arr[i] = GetWriteableValue(arr[i]);&lt;br /&gt;			}&lt;br /&gt;&lt;br /&gt;			file.WriteLine(string.Join(",", arr));&lt;br /&gt;		}&lt;br /&gt;&lt;br /&gt;		for(int j = 0; j&lt;dt.Rows.Count; j++)&lt;br /&gt;		{&lt;br /&gt;			string[] dataArr = new String[dt.Columns.Count];&lt;br /&gt;			for(int i = 0; i&lt;dt.Columns.Count; i++)&lt;br /&gt;			{&lt;br /&gt;				object o = dt.Rows[j][i];&lt;br /&gt;				dataArr[i] = GetWriteableValue(o);&lt;br /&gt;			}&lt;br /&gt;			file.WriteLine(string.Join(",", dataArr));&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public static string GetWriteableValue(object o)&lt;br /&gt;	{&lt;br /&gt;		if(o==null || o == Convert.DBNull)&lt;br /&gt;			return "";&lt;br /&gt;		else if(o.ToString().IndexOf(",")==-1)&lt;br /&gt;			return o.ToString();&lt;br /&gt;		else&lt;br /&gt;			return "\"" + o.ToString() + "\"";&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-4956918365224477133?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/4956918365224477133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/export-datatable-into-csv.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4956918365224477133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4956918365224477133'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/export-datatable-into-csv.html' title='Export DataTable into CSV'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-9053621154587331302</id><published>2009-05-18T00:40:00.000-07:00</published><updated>2009-05-18T00:41:16.467-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>To Remove specfic string from Collection of string</title><content type='html'>/// &lt;summary&gt;&lt;br /&gt;        /// To Remove specfic string from Collection of string&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;        /// &lt;param name="strNames"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;param name="sep"&gt;&lt;/param&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;        public static string mRemoveStringFromCollection(string strNames, string sep, string specificStr)&lt;br /&gt;        {&lt;br /&gt;            List&lt;string&gt; list = new List&lt;string&gt;();&lt;br /&gt;            string strValue = String.Empty;&lt;br /&gt;            if (!string.IsNullOrEmpty(strNames))&lt;br /&gt;            {&lt;br /&gt;                list.AddRange(Regex.Split(strNames, sep));&lt;br /&gt;                foreach (string str in list)&lt;br /&gt;                {&lt;br /&gt;                    if (!str.Contains(specificStr))&lt;br /&gt;                    {&lt;br /&gt;                        if (string.IsNullOrEmpty(strValue))&lt;br /&gt;                        {&lt;br /&gt;                            strValue = str;&lt;br /&gt;                        }&lt;br /&gt;                        else&lt;br /&gt;                        {&lt;br /&gt;                            strValue = strValue + sep + str;&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                return strValue;&lt;br /&gt;            }&lt;br /&gt;            return strNames;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-9053621154587331302?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/9053621154587331302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/to-remove-specfic-string-from.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/9053621154587331302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/9053621154587331302'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/to-remove-specfic-string-from.html' title='To Remove specfic string from Collection of string'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6218715208700117764</id><published>2009-05-18T00:38:00.000-07:00</published><updated>2009-05-18T00:39:12.352-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><category scheme='http://www.blogger.com/atom/ns#' term='WinForms'/><title type='text'>Setting Opacity of WinForm</title><content type='html'>public static void mSetOpacity(Form form)&lt;br /&gt;        {&lt;br /&gt;            form.Opacity = 0.05;&lt;br /&gt;            for(double i=0.20; i &lt; 1; i+=0.20)&lt;br /&gt;            {&lt;br /&gt;                form.Opacity = System.Math.Round(i, 2);&lt;br /&gt;                &lt;br /&gt;                System.Threading.Thread.Sleep(5);&lt;br /&gt;                &lt;br /&gt;            }&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6218715208700117764?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6218715208700117764/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/setting-opacity-of-winform.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6218715208700117764'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6218715208700117764'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/setting-opacity-of-winform.html' title='Setting Opacity of WinForm'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3936162356734494298</id><published>2009-05-17T22:41:00.000-07:00</published><updated>2009-05-17T22:42:06.591-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Alert Message in ASP.net</title><content type='html'>public static string GetAlert(string Message)&lt;br /&gt;{&lt;br /&gt;string Script = "";&lt;br /&gt;Script += "&lt;script language=JavaScript&gt;\n";&lt;br /&gt;Script += "alert('" + Message + "') \n";&lt;br /&gt;Script += "&lt;/script&gt;";&lt;br /&gt;return Script;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;I code behind:&lt;br /&gt;&lt;br /&gt;Script = VetCareUtilities.GetAlert("File does not exists");&lt;br /&gt;Page.ClientScript.RegisterStartupScript(typeof(Page), "Filedoesnotexists", Script);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3936162356734494298?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3936162356734494298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/alert-message-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3936162356734494298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3936162356734494298'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/alert-message-in-aspnet.html' title='Alert Message in ASP.net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6695333242750130862</id><published>2009-05-16T00:07:00.000-07:00</published><updated>2009-05-16T00:08:13.967-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>Update Database with DataGridView+Update Command</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.ComponentModel;&lt;br /&gt;using System.Data;&lt;br /&gt;using System.Drawing;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Windows.Forms;&lt;br /&gt;using System.Data.OracleClient;&lt;br /&gt;&lt;br /&gt;namespace Trans829115.PL&lt;br /&gt;{&lt;br /&gt;    public partial class frmUpdateDBViaDataGridView : Form&lt;br /&gt;    {&lt;br /&gt;        private OracleConnection connection;&lt;br /&gt;        private OracleCommand command;&lt;br /&gt;        private OracleDataAdapter adapter;&lt;br /&gt;        private OracleCommandBuilder builder;&lt;br /&gt;        private DataSet ds;&lt;br /&gt;        private DataTable userTable;&lt;br /&gt;        private bool mAllowInsert;&lt;br /&gt;        private bool mAllowDelete;&lt;br /&gt;        private bool IsDirty = false;&lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;        public frmUpdateDBViaDataGridView()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;&lt;br /&gt;            // In Form control definition&lt;br /&gt;&lt;br /&gt;            connection = new OracleConnection(BLL.QuerySet.ConString);&lt;br /&gt;            command = new OracleCommand(BLL.QuerySet.UpFTP, connection);&lt;br /&gt;            adapter = new OracleDataAdapter(command);&lt;br /&gt;            builder = new OracleCommandBuilder(adapter);&lt;br /&gt;            ds = new DataSet();&lt;br /&gt;            adapter.Fill(ds);&lt;br /&gt;            userTable = ds.Tables[0];&lt;br /&gt;&lt;br /&gt;            userDataGridView.AllowUserToAddRows = true;&lt;br /&gt;            userDataGridView.AllowUserToDeleteRows  = true;&lt;br /&gt;            btnDelete.Enabled = true;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void btnDelete_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Delete();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void frmUpdateDBViaDataGridView_Load(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;           userDataGridView.DataSource = userTable.DefaultView;&lt;br /&gt;            lblRowCount.Text = "Number of records: " + userTable.Rows.Count.ToString();&lt;br /&gt;            userDataGridView.AllowUserToResizeColumns = true;&lt;br /&gt;            if (userTable.Rows.Count == 0)&lt;br /&gt;            {&lt;br /&gt;                btnDelete.Enabled = false;&lt;br /&gt;                btnUpdate.Enabled = false;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Delete()&lt;br /&gt;        {&lt;br /&gt;            if (MessageBox.Show("Do you really want to delete the selected record(s)?",&lt;br /&gt;                   "Delete records", MessageBoxButtons.YesNo,&lt;br /&gt;                   MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false)&lt;br /&gt;                   == DialogResult.Yes)&lt;br /&gt;            {&lt;br /&gt;                try&lt;br /&gt;                {&lt;br /&gt;                    &lt;br /&gt;                    int cnt = userDataGridView.SelectedRows.Count;&lt;br /&gt;                    for (int i = 0; i &lt; cnt; i++)&lt;br /&gt;                    {&lt;br /&gt;                        if (this.userDataGridView.SelectedRows.Count &gt; 0 &amp;&amp;&lt;br /&gt;                            this.userDataGridView.SelectedRows[0].Index !=&lt;br /&gt;                            this.userDataGridView.Rows.Count - 1)&lt;br /&gt;                        {&lt;br /&gt;                            this.userDataGridView.Rows.RemoveAt(&lt;br /&gt;                               this.userDataGridView.SelectedRows[0].Index);&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    if(ds.HasChanges())&lt;br /&gt;                    {&lt;br /&gt;                        DataTable changes = ds.Tables[0].GetChanges(); &lt;br /&gt;&lt;br /&gt;if (changes != null) &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;adapter.Update(changes);&lt;br /&gt;ds.Tables[0].AcceptChanges(); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                    }&lt;br /&gt;                    &lt;br /&gt;                }&lt;br /&gt;                catch (Exception ex)&lt;br /&gt;                {&lt;br /&gt;                    MessageBox.Show(ex.ToString());&lt;br /&gt;                }&lt;br /&gt;                finally&lt;br /&gt;                {&lt;br /&gt;                    &lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            if (userTable.Rows.Count == 0)&lt;br /&gt;            {&lt;br /&gt;                btnUpdate.Enabled = false;&lt;br /&gt;                if (mAllowDelete) btnDelete.Enabled = false;&lt;br /&gt;            }&lt;br /&gt;            IsDirty = true;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void Update()&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                connection.Open();&lt;br /&gt;                adapter.UpdateCommand = builder.GetUpdateCommand();&lt;br /&gt;                adapter.Update(userTable);&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;                MessageBox.Show(ex.ToString());&lt;br /&gt;            }&lt;br /&gt;            finally&lt;br /&gt;            {&lt;br /&gt;                connection.Close();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void btnUpdate_Click(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            Update();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void frmUpdateDBViaDataGridView_FormClosing(object sender, FormClosingEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (IsDirty)&lt;br /&gt;                if (MessageBox.Show("Do you want to save changes?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes)&lt;br /&gt;                    Update(); &lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void userDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (IsDirty)&lt;br /&gt;                if (MessageBox.Show("Do you want to save changes?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2, 0, false) == DialogResult.Yes)&lt;br /&gt;                    Update(); &lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void userDataGridView_KeyDown(object sender, KeyEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (e.KeyCode == Keys.Delete) Delete();&lt;br /&gt;            e.Handled = true; // Cancel &lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6695333242750130862?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6695333242750130862/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/update-database-with-datagridviewupdate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6695333242750130862'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6695333242750130862'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/update-database-with-datagridviewupdate.html' title='Update Database with DataGridView+Update Command'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2860814043896993627</id><published>2009-05-16T00:04:00.001-07:00</published><updated>2009-05-16T00:05:49.278-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>Encryption and Decryption in .NET</title><content type='html'>public class EnCodingDeCoding&lt;br /&gt;            {&lt;br /&gt;        public static string Encode(string sData)&lt;br /&gt;        {&lt;br /&gt;        try&lt;br /&gt;        {&lt;br /&gt;        byte[] encData_byte = new byte[sData.Length];&lt;br /&gt;&lt;br /&gt;        encData_byte = System.Text.Encoding.UTF8.GetBytes(sData); &lt;br /&gt;&lt;br /&gt;        string encodedData = Convert.ToBase64String(encData_byte);&lt;br /&gt;&lt;br /&gt;        return encodedData;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;        catch(Exception ex)&lt;br /&gt;        {&lt;br /&gt;        throw new Exception("Error in base64Encode" + ex.Message);&lt;br /&gt;        }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public static string Decode(string sData)&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;        System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding(); &lt;br /&gt;&lt;br /&gt;        System.Text.Decoder utf8Decode = encoder.GetDecoder();&lt;br /&gt;&lt;br /&gt;        byte[] todecode_byte = Convert.FromBase64String(sData);&lt;br /&gt;&lt;br /&gt;        int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length); &lt;br /&gt;&lt;br /&gt;        char[] decoded_char = new char[charCount];&lt;br /&gt;&lt;br /&gt;        utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0); &lt;br /&gt;&lt;br /&gt;        string result = new String(decoded_char);&lt;br /&gt;&lt;br /&gt;        return result;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;    &lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2860814043896993627?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2860814043896993627/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/encryption-and-decryption-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2860814043896993627'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2860814043896993627'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/encryption-and-decryption-in-net.html' title='Encryption and Decryption in .NET'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5880960360570925168</id><published>2009-05-15T04:42:00.000-07:00</published><updated>2009-05-15T04:45:59.573-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>How to get IPAddress in .Net</title><content type='html'>public static string mGetIPAddress()&lt;br /&gt;        {&lt;br /&gt;            string strHostName = Dns.GetHostName();&lt;br /&gt;            string strIPAddress = "";&lt;br /&gt;&lt;br /&gt;            IPHostEntry iphostentry = Dns.GetHostEntry(strHostName);&lt;br /&gt;&lt;br /&gt;            foreach (IPAddress ipaddress in iphostentry.AddressList)&lt;br /&gt;            {&lt;br /&gt;                strIPAddress = ipaddress.ToString();&lt;br /&gt;            }&lt;br /&gt;            return strIPAddress;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5880960360570925168?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5880960360570925168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-get-ipaddress-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5880960360570925168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5880960360570925168'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-get-ipaddress-in-net.html' title='How to get IPAddress in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5092695055143894334</id><published>2009-05-15T04:33:00.000-07:00</published><updated>2009-05-15T04:34:33.486-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C#.Net'/><title type='text'>How to get Gateway in .NET</title><content type='html'>using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.Text;&lt;br /&gt;using System.Net.NetworkInformation;&lt;br /&gt;&lt;br /&gt;    public class ClsGatewayID&lt;br /&gt;    {&lt;br /&gt;        private static string _GatewayID = string.Empty;&lt;br /&gt;&lt;br /&gt;        public static string GatewayID&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return mGetGatewayID();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static string mGetGatewayID()&lt;br /&gt;        {&lt;br /&gt;            NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();&lt;br /&gt;            foreach (NetworkInterface adapter in adapters)&lt;br /&gt;            {&lt;br /&gt;                IPInterfaceProperties adapterProperties = adapter.GetIPProperties();&lt;br /&gt;                GatewayIPAddressInformationCollection addresses = adapterProperties.GatewayAddresses;&lt;br /&gt;                    if (addresses.Count &gt; 0)&lt;br /&gt;                    {&lt;br /&gt;                        foreach (GatewayIPAddressInformation address in addresses)&lt;br /&gt;                        {&lt;br /&gt;                        &lt;br /&gt;                          if(string.IsNullOrEmpty(_GatewayID))&lt;br /&gt;                              _GatewayID += address.Address.ToString();&lt;br /&gt;                          else&lt;br /&gt;                              _GatewayID += address.Address.ToString() + "\r\n";&lt;br /&gt;&lt;br /&gt;                        }&lt;br /&gt;                    }&lt;br /&gt;             }&lt;br /&gt;&lt;br /&gt;            return _GatewayID;&lt;br /&gt;        }&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5092695055143894334?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5092695055143894334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-get-gateway-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5092695055143894334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5092695055143894334'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-get-gateway-in-net.html' title='How to get Gateway in .NET'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3011647217352276419</id><published>2009-05-13T22:24:00.000-07:00</published><updated>2009-05-13T22:41:57.932-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>How to use Favicon in ASP.net</title><content type='html'>To display your own icon on the browser address bar when visitors view or bookmark your web page?    &lt;br /&gt;&lt;br /&gt;Note: '&lt;' is replace with '[' so that blog's editor can not resolve the HTML tags on this page&lt;br /&gt;&lt;br /&gt;[link runat="server" rel="shortcut icon" href="~/favicon.ico" type="image/x- icon" /]&lt;br /&gt;[link runat="server" rel="icon" href="~/favicon.ico" type="image/ico" /] &lt;br /&gt;&lt;br /&gt;Put the above text in header section of your html&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3011647217352276419?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3011647217352276419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-use-favicon-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3011647217352276419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3011647217352276419'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-use-favicon-in-aspnet.html' title='How to use Favicon in ASP.net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-746343969385624557</id><published>2009-05-13T22:15:00.000-07:00</published><updated>2009-05-13T22:18:10.332-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>Get the name of previous page in ASP.Net</title><content type='html'>public static string mGetPreviousPage()&lt;br /&gt;{&lt;br /&gt;if (Request.UrlReferrer != null)&lt;br /&gt;{&lt;br /&gt;string strPage = Request.UrlReferrer.Segments[Request.UrlReferrer.Segments.Length - 1];&lt;br /&gt;return strPage;&lt;br /&gt;}&lt;br /&gt;return null; // No Previous page found&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-746343969385624557?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/746343969385624557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/get-name-of-previous-page-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/746343969385624557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/746343969385624557'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/get-name-of-previous-page-in-aspnet.html' title='Get the name of previous page in ASP.Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-6857349261710677360</id><published>2009-05-11T22:20:00.000-07:00</published><updated>2009-05-11T22:22:56.588-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How to Convert DataGridView into HTML Table'/><title type='text'>How to Convert DataGridView into HTML Table</title><content type='html'>public static StringBuilder DataGridToHMTLTable(System.Windows.Forms.DataGridView dg)&lt;br /&gt;            {&lt;br /&gt;                StringBuilder sb = new StringBuilder();&lt;br /&gt;                //Setting HTML and table tags&lt;br /&gt;                sb.AppendLine("&lt;html&gt;&lt;body&gt;&lt;center&gt;&lt;" + &lt;br /&gt;                                "table border='2' cellpadding='1' cellspacing='1'&gt;");&lt;br /&gt;                sb.AppendLine("&lt;tr&gt;");&lt;br /&gt;                //setting table headers&lt;br /&gt;                for (int i = 0; i &lt; dg.Columns.Count; i++)&lt;br /&gt;                {&lt;br /&gt;                    sb.AppendLine("&lt;td align='center' valign='middle'&gt;" + &lt;br /&gt;                                    dg.Columns[i].HeaderText + "&lt;/td&gt;");&lt;br /&gt;                }&lt;br /&gt;                //Table body&lt;br /&gt;                sb.AppendLine("&lt;tr&gt;");&lt;br /&gt;                for (int i = 0; i &lt; dg.Rows.Count; i++)&lt;br /&gt;                {&lt;br /&gt;                    sb.AppendLine("&lt;tr&gt;");&lt;br /&gt;                    foreach (DataGridViewCell dgvc in dg.Rows[i].Cells)&lt;br /&gt;                    {&lt;br /&gt;                        sb.AppendLine("&lt;td align='center' valign='middle'&gt;" + &lt;br /&gt;                                        dgvc.Value.ToString() + "&lt;/td&gt;");&lt;br /&gt;                    }&lt;br /&gt;                    sb.AppendLine("&lt;/tr&gt;");&lt;br /&gt;&lt;br /&gt;                }&lt;br /&gt;                //Table Footer and End of HTML Tag&lt;br /&gt;                sb.AppendLine("&lt;/table&gt;&lt;/center&gt;&lt;/body&gt;&lt;/html&gt;");&lt;br /&gt;                return sb;&lt;br /&gt;            } &lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-6857349261710677360?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/6857349261710677360/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-convert-datagridview-into-html.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6857349261710677360'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/6857349261710677360'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-convert-datagridview-into-html.html' title='How to Convert DataGridView into HTML Table'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8753229477811363410</id><published>2009-05-11T03:22:00.000-07:00</published><updated>2009-05-11T03:23:06.021-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='How to use the radiobutton in WPF and XAML.'/><title type='text'>How to use the radiobutton in WPF and XAML</title><content type='html'>WPF RadioButton Control:&lt;br /&gt; &lt;br /&gt;RadioButton controls are usually grouped together to offer user a single choice among several options (only one button at a time can be selected).&lt;br /&gt; &lt;br /&gt;&lt;RadioButton&gt; &lt;/Radiobutton&gt; tag is used too create the radio button in XAML.&lt;br /&gt; &lt;br /&gt;Properties:&lt;br /&gt;In the following tag  I create the RadioButton in which Height is height of the RadioButton, Name is the nameof the RadioButton, text in the between the RadioButton tag is the centent visibile to user. Background the the color of the box, Borderbrush is the color of the border, Forground is the color of the text.&lt;br /&gt; &lt;br /&gt;&lt;RadioButton Height="16" Margin="26,18,132,0" Name="RadioButton_Option1" VerticalAlignment="Top" Background="Snow" BorderBrush="Black"  GroupName="Visit_eggHeadcafe.com" Foreground="DarkBlue"&gt;ASP.net Articles &lt;/RadioButton&gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;To change the orientation from left to right use the FlowDirection property to RightToLeft.&lt;br /&gt;&lt;br /&gt; RadioButton is used in the group so that user can select only one option from the available options (No extra coding is required to uncheck others). Use same GroupName of the radiobuttons to mark in a group so that only one option can be selected as follows.&lt;br /&gt; &lt;br /&gt;&lt;StackPanel &gt;&lt;br /&gt;        &lt;RadioButton Height="16" Margin="26,18,132,0" Name="RadioButton_Option1" VerticalAlignment="Top" Background="Snow" BorderBrush="Black"  GroupName="Visit_eggHeadcafe.com" Foreground="DarkBlue"&gt;ASP.net Articles &lt;/RadioButton&gt;&lt;br /&gt;        &lt;RadioButton Height="16" Margin="26,18,132,0" Name="RadioButton_Option2" VerticalAlignment="Top" Background="Snow" BorderBrush="Black"  GroupName="Visit_eggHeadcafe.com" Foreground="DarkBlue"&gt;C# Articles&lt;/RadioButton&gt;&lt;br /&gt;        &lt;RadioButton Height="16" Margin="26,18,132,0" Name="RadioButton_Option3" VerticalAlignment="Top" Background="Snow" BorderBrush="Black"  GroupName="Visit_eggHeadcafe.com" Foreground="DarkBlue"&gt;ADO.net Articles&lt;/RadioButton&gt;&lt;br /&gt;        &lt;RadioButton Height="17" Margin="26,18,115,0" Name="RadioButton_Option4" VerticalAlignment="Top" Background="Snow" BorderBrush="Black"  GroupName="Visit_eggHeadcafe.com" Foreground="DarkBlue" Width="164"&gt;SQL Server 2005 Articles&lt;/RadioButton&gt;&lt;br /&gt;        &lt;Button  Margin="26,18,132,0" Width="75" Height="20" Click="Button_Click"&gt;Open Articles&lt;/Button&gt;&lt;br /&gt;        &lt;/StackPanel &gt; &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Events:&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Now write the code to the handler so that we can take appropriate action on these events in windows1.xaml.cs.&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;Finding out which radiobutton is checked use the property IsChecked as follows in the btnShow  button&lt;br /&gt; &lt;br /&gt;        private void btnShow_Click(object sender, RoutedEventArgs e)&lt;br /&gt;        {&lt;br /&gt;            if (RadioButton_Option1.IsChecked==true)&lt;br /&gt;&lt;br /&gt;                System.Diagnostics.Process.Start(@"http://www.eggheadcafe.com/ASPNetBlog.aspx");&lt;br /&gt;                else if(RadioButton_Option2.IsChecked==true)&lt;br /&gt;                System.Diagnostics.Process.Start(@"http://www.eggheadcafe.com/CSharpBlog.aspx");&lt;br /&gt;                else if(RadioButton_Option3.IsChecked==true)&lt;br /&gt;                System.Diagnostics.Process.Start(@"http://www.eggheadcafe.com/ADONetBlog.aspx");&lt;br /&gt;                else if(RadioButton_Option4.IsChecked==true)&lt;br /&gt;                System.Diagnostics.Process.Start(@"http://www.eggheadcafe.com/SQLServerBlog.aspx");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        } &lt;br /&gt; &lt;br /&gt;Summary: Radio button is very simple control and used for selecting only one option from the available options.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8753229477811363410?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8753229477811363410/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-use-radiobutton-in-wpf-and-xaml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8753229477811363410'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8753229477811363410'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-use-radiobutton-in-wpf-and-xaml.html' title='How to use the radiobutton in WPF and XAML'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5744050552898314142</id><published>2009-05-11T02:33:00.000-07:00</published><updated>2009-05-11T02:35:13.177-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='3-Tier architecture in .Net'/><title type='text'>3-Tier architecture in .Net</title><content type='html'>3-Tier architecture generally contains UI or Presentation Layer, Business Access Layer (BAL) or Business Logic Layer and Data Access Layer (DAL). &lt;br /&gt;&lt;br /&gt;Presentation Layer (UI) &lt;br /&gt;Presentation layer cotains pages like .aspx or windows form where data is presented to the user or input is taken from the user. &lt;br /&gt;&lt;br /&gt;Business Access Layer (BAL) or Business Logic Layer &lt;br /&gt;BAL contains business logic, validations or calculations related with the data, if needed. I will call it Business Access Layer in my demo. &lt;br /&gt;&lt;br /&gt;Data Access Layer (DAL) &lt;br /&gt;DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating data (insert, update, delete etc). For this demo application, I have taken a very simple example. I am assuming that I have to play with record of persons (FirstName, LastName, Age) and I will refer only these data through out this article. &lt;br /&gt;&lt;br /&gt;Designing 3-Tier Architecture &lt;br /&gt;&lt;br /&gt;For the ease of understanding, I have created BAL, DAL into the App_Code folder. In real scenario, you should create separate projects for BAL, DAL (as Class Library) and UI (as Web project) and reference your BAL into UI. &lt;br /&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Data Access Layer &lt;br /&gt;Lets proceed with desiging 3-Tier architecture. To do that lets proceed with DAL, BAL and then UI. Add a class named by right clicking App_Code folder. (In my case I have a 3-Tier folder inside App_Code folder, you can directly add inside App_Code or you can create a separate project for DAL and add reference of this project into your BAL.) and copy-paste folowing code (Your can overwrite your default written code for the class file by pasting this code). Here, I have assumed that you will create the respective stored procedure yourself into the database or you may download attachment from http://www.dotnetfunda.com/articles/article18.aspx article and look for App_Data folder for complete database structure and stored procedure for this article. &lt;br /&gt;&lt;br /&gt;Data Access Layer (DAL)&lt;br /&gt;&lt;br /&gt;Code for Data Access Layer &lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;using System.Data;&lt;br /&gt;&lt;br /&gt;using System.Configuration;&lt;br /&gt;&lt;br /&gt;using System.Web;&lt;br /&gt;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;using System.Data.SqlClient;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;    /// Summary description for PersonDAL3&lt;br /&gt;&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;    public class PersonDAL3&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        string connStr = ConfigurationManager.ConnectionStrings["TutTestConn"].ToString();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public PersonDAL3()&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// Used to insert records into database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="firstName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="lastName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="age"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public int Insert(string firstName, string lastName, int age)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            SqlConnection conn = new SqlConnection(connStr);&lt;br /&gt;&lt;br /&gt;            conn.Open();&lt;br /&gt;&lt;br /&gt;            SqlCommand dCmd = new SqlCommand("InsertData", conn);&lt;br /&gt;&lt;br /&gt;            dCmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@firstName", firstName);&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@lastName", lastName);&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@age", age);&lt;br /&gt;&lt;br /&gt;                return dCmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dCmd.Dispose();&lt;br /&gt;&lt;br /&gt;                conn.Close();&lt;br /&gt;&lt;br /&gt;                conn.Dispose();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// Update record into database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="personID"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="firstName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="lastName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="age"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public int Update(int personID, string firstName, string lastName, int age)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            SqlConnection conn = new SqlConnection(connStr);&lt;br /&gt;&lt;br /&gt;            conn.Open();&lt;br /&gt;&lt;br /&gt;            SqlCommand dCmd = new SqlCommand("UpdateData", conn);&lt;br /&gt;&lt;br /&gt;            dCmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@firstName", firstName);&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@lastName", lastName);&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@age", age);&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@personID", personID);&lt;br /&gt;&lt;br /&gt;                return dCmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dCmd.Dispose();&lt;br /&gt;&lt;br /&gt;                conn.Close();&lt;br /&gt;&lt;br /&gt;                conn.Dispose();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// Load all records from database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public DataTable Load()&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            SqlConnection conn = new SqlConnection(connStr);&lt;br /&gt;&lt;br /&gt;            SqlDataAdapter dAd = new SqlDataAdapter("LoadAll", conn);&lt;br /&gt;&lt;br /&gt;            dAd.SelectCommand.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;            DataSet dSet = new DataSet();&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dAd.Fill(dSet, "PersonTable");&lt;br /&gt;&lt;br /&gt;                return dSet.Tables["PersonTable"];&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dSet.Dispose();&lt;br /&gt;&lt;br /&gt;                dAd.Dispose();&lt;br /&gt;&lt;br /&gt;                conn.Close();&lt;br /&gt;&lt;br /&gt;                conn.Dispose();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// Delete record from database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="personID"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public int Delete(int personID)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            SqlConnection conn = new SqlConnection(connStr);&lt;br /&gt;&lt;br /&gt;            conn.Open();&lt;br /&gt;&lt;br /&gt;            SqlCommand dCmd = new SqlCommand("DeleteData", conn);&lt;br /&gt;&lt;br /&gt;            dCmd.CommandType = CommandType.StoredProcedure;&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dCmd.Parameters.AddWithValue("@personID", personID);&lt;br /&gt;&lt;br /&gt;                return dCmd.ExecuteNonQuery();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                dCmd.Dispose();&lt;br /&gt;&lt;br /&gt;                conn.Close();&lt;br /&gt;&lt;br /&gt;                conn.Dispose();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the above code, I have a member variable called connStr that is getting database connection string from my web.config file that is being used through out the class. I have separate method for inserting, deleting, updating records into database and loading records from database. I am not goint into details of how I am connecting database and manipulating the data just to make this tutorials short. &lt;br /&gt;&lt;br /&gt;Business Access Layer (BAL)&lt;br /&gt;&lt;br /&gt;Now, create a class named PersonBAL3 into App_Code folder by right clicking it and write respective methods for calling Insert, Delete, Update and Load methods of Data Access Layer class file (PersonDAL3) (In my case I have a 3-Tier folder inside App_Code folder, you can directly add inside App_Code or you can create a separate project for BAL and add reference of this project into your Presentation Layer). As we don't have any business logic here so simply instantiate the PersonDAL3 class of DAL and call methods. Below is the code for BAL (Your can overwrite your default written code for the class file by pasting this code). &lt;br /&gt;&lt;br /&gt;Code for Business Access Layer &lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;using System;&lt;br /&gt;&lt;br /&gt;using System.Data;&lt;br /&gt;&lt;br /&gt;using System.Configuration;&lt;br /&gt;&lt;br /&gt;using System.Web;&lt;br /&gt;&lt;br /&gt;using System.Web.Security;&lt;br /&gt;&lt;br /&gt;using System.Web.UI;&lt;br /&gt;&lt;br /&gt;using System.Web.UI.WebControls;&lt;br /&gt;&lt;br /&gt;using System.Web.UI.WebControls.WebParts;&lt;br /&gt;&lt;br /&gt;using System.Web.UI.HtmlControls;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;    /// Summary description for PersonBAL3&lt;br /&gt;&lt;br /&gt;    /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;    public class PersonBAL3&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        public PersonBAL3()&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// insert records into database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="firstName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="lastName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="age"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public int Insert(string firstName, string lastName, int age)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            PersonDAL3 pDAL = new PersonDAL3();&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                return pDAL.Insert(firstName, lastName, age);&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                pDAL = null;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// Update records into database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="personID"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="firstName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="lastName"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="age"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public int Update(int personID, string firstName, string lastName, int age)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            PersonDAL3 pDAL = new PersonDAL3();&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                return pDAL.Update(personID, firstName, lastName, age);&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                pDAL = null;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// Load records from database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public DataTable Load()&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            PersonDAL3 pDAL = new PersonDAL3();&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                return pDAL.Load();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                pDAL = null;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;summary&gt;&lt;br /&gt;&lt;br /&gt;        /// Delete record from database&lt;br /&gt;&lt;br /&gt;        /// &lt;/summary&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;param name="personID"&gt;&lt;/param&gt;&lt;br /&gt;&lt;br /&gt;        /// &lt;returns&gt;&lt;/returns&gt;&lt;br /&gt;&lt;br /&gt;        public int Delete(int personID)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            PersonDAL3 pDAL = new PersonDAL3();&lt;br /&gt;&lt;br /&gt;            try&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                return pDAL.Delete(personID);&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                throw;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            finally&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                pDAL = null;&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Till now we haev our Business Access Layer and Database Access Layer ready. Now we have to write our Presentation Layer that will use our Business Access Layer methods. Lets create a form that will have three textboxes for FirstName, LastName and Age. &lt;br /&gt;&lt;br /&gt;Presentation Layer&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Create an Insert.aspx page (make is as Startup page) and copy paste following code to bring the insert form something like displaying in the picture. &lt;br /&gt;Code for Insert Record form &lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;&lt;asp:Label ID="lblMessage" runat="Server" ForeColor="red" EnableViewState="False"&gt;&lt;/asp:Label&gt;&lt;br /&gt;&lt;br /&gt;        &lt;table style="border:2px solid #cccccc;"&gt;&lt;br /&gt;&lt;br /&gt;            &lt;tr style="background-color:#507CD1;color:White;"&gt;&lt;br /&gt;&lt;br /&gt;                &lt;th colspan="3"&gt;Add Records&lt;/th&gt;&lt;br /&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;            &lt;tr&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    First Name:&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:TextBox ID="txtFirstName" runat="Server"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:RequiredFieldValidator ID="req1" runat="Server" Text="*" ControlToValidate="txtFirstName" &lt;br /&gt;&lt;br /&gt;                         Display="dynamic"&gt;&lt;/asp:RequiredFieldValidator&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;            &lt;tr&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    Last Name:&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:TextBox ID="txtLastName" runat="Server"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:RequiredFieldValidator ID="req2" runat="Server" Text="*" ControlToValidate="txtLastName" &lt;br /&gt;&lt;br /&gt;                      Display="dynamic"&gt;&lt;/asp:RequiredFieldValidator&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;            &lt;tr&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    Age:&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:TextBox ID="txtAge" runat="Server" Columns="4"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:RequiredFieldValidator ID="req3" runat="Server" Text="*" ControlToValidate="txtAge" &lt;br /&gt;&lt;br /&gt;                        Display="dynamic"&gt;&lt;/asp:RequiredFieldValidator&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:CompareValidator ID="Comp1" runat="Server" Text="Only integer" ControlToValidate="txtAge" &lt;br /&gt;&lt;br /&gt;                       Operator="DataTypeCheck" Type="Integer"&gt;&lt;/asp:CompareValidator&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;            &lt;tr&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;br /&gt;&lt;br /&gt;                &lt;td&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="AddRecords" /&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/td&gt;&lt;br /&gt;&lt;br /&gt;            &lt;/tr&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now, lets write method that will fire when Submit button will be clicked on the from. &lt;br /&gt;Code for AddRecords method &lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;protected void AddRecords(object sender, EventArgs e)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        //Lets validate the page first&lt;br /&gt;&lt;br /&gt;        if (!Page.IsValid)&lt;br /&gt;&lt;br /&gt;            return;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        int intResult = 0;&lt;br /&gt;&lt;br /&gt;        // Page is valid, lets go ahead and insert records&lt;br /&gt;&lt;br /&gt;        // Instantiate BAL object&lt;br /&gt;&lt;br /&gt;        PersonBAL3 pBAL = new PersonBAL3();&lt;br /&gt;&lt;br /&gt;        // Instantiate the object we have to deal with&lt;br /&gt;&lt;br /&gt;        string firstName = txtFirstName.Text;&lt;br /&gt;&lt;br /&gt;        string lastName = txtLastName.Text;&lt;br /&gt;&lt;br /&gt;        int age = Int32.Parse(txtAge.Text);&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            intResult = pBAL.Insert(firstName, lastName, age);&lt;br /&gt;&lt;br /&gt;            if (intResult &gt; 0)&lt;br /&gt;&lt;br /&gt;                lblMessage.Text = "New record inserted successfully.";&lt;br /&gt;&lt;br /&gt;            else&lt;br /&gt;&lt;br /&gt;                lblMessage.Text = "FirstName [&lt;b&gt;"+ txtFirstName.Text +"&lt;/b&gt;] alredy exists, try another name";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (Exception ee)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            lblMessage.Text = ee.Message.ToString();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        finally&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            pBAL = null;&lt;br /&gt;&lt;br /&gt;        }        &lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the above code, first I am validating the page by using Page.IsValid method just to check if correct data has been entered. Then I have instantiated PersonBAL3 and calling Insert method of it (pBAL.Insert) by passing firstName, lastName, age as parameter. &lt;br /&gt;&lt;br /&gt;Dispalying Records into GridView &lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Create a .aspx file called List.aspx and create a GridView something like displayed into the picture. To list the record into GridView that will also enable us to Edit, Delete record, copy paste following code. &lt;br /&gt;&lt;br /&gt;Code for GridView &lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;&lt;asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"&lt;br /&gt;&lt;br /&gt;         DataKeyNames="PersonID" AutoGenerateEditButton="True" AutoGenerateColumns="False"&lt;br /&gt;&lt;br /&gt;          OnRowEditing="EditRecord" OnRowUpdating="UpdateRecord" OnRowCancelingEdit="CancelRecord"&lt;br /&gt;&lt;br /&gt;           OnRowDeleting="DeleteRecord" PageSize="5" &gt;&lt;br /&gt;&lt;br /&gt;            &lt;FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;RowStyle BackColor="#EFF3FB" /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;EditRowStyle BackColor="#2ff1BF" /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;AlternatingRowStyle BackColor="White" /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;Columns&gt;&lt;br /&gt;&lt;br /&gt;                &lt;asp:BoundField DataField="PersonID" HeaderText="Person ID" ReadOnly="True"  SortExpression="PersonID" /&gt;&lt;br /&gt;&lt;br /&gt;                &lt;asp:TemplateField HeaderText="First Name" SortExpression="FirstName"&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;%# Eval("FirstName") %&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;EditItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;asp:TextBox ID="txtFName" runat="Server" Text='&lt;%# Eval("FirstName") %&gt;'&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/EditItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/asp:TemplateField&gt;&lt;br /&gt;&lt;br /&gt;                &lt;asp:TemplateField HeaderText="Last Name" SortExpression="LastName"&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;%# Eval("LastName") %&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;EditItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;asp:TextBox ID="txtLName" runat="Server" Text='&lt;%# Eval("LastName") %&gt;'&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/EditItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/asp:TemplateField&gt;&lt;br /&gt;&lt;br /&gt;                &lt;asp:TemplateField HeaderText="Age" SortExpression="Age"&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;%# Eval("Age") %&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;EditItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;asp:TextBox ID="txtAge" runat="Server" Text='&lt;%# Eval("Age") %&gt;'&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/EditItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/asp:TemplateField&gt;&lt;br /&gt;&lt;br /&gt;                &lt;asp:TemplateField HeaderText="Delete?"&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;span onclick="return confirm('Are you sure to Delete?')"&gt;&lt;br /&gt;&lt;br /&gt;                            &lt;asp:LinkButton ID="lnBD" runat="server" Text="Delete" CommandName="Delete"&gt;&lt;/asp:LinkButton&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                    &lt;/ItemTemplate&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/asp:TemplateField&gt;&lt;br /&gt;&lt;br /&gt;            &lt;/Columns&gt;&lt;br /&gt;&lt;br /&gt;        &lt;/asp:GridView&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Code to Load records and Displaying Records into GridView &lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;private DataTable BindGrid()&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        PersonBAL3 p = new PersonBAL3();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            DataTable dTable = p.Load();&lt;br /&gt;&lt;br /&gt;            GridView1.DataSource = dTable;&lt;br /&gt;&lt;br /&gt;            GridView1.DataBind();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (Exception ee)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            lblMessage.Text = ee.Message.ToString();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        finally&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            p = null;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        return dTable;&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In the above method I am instantiating PersonBAL3 class and calling Load method to get the record into DataTable and binding it into GridView. &lt;br /&gt;&lt;br /&gt;Code to Delete Records &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;protected void DeleteRecord(object sender, GridViewDeleteEventArgs e)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        int personID = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString()); &lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // instantiate BAL&lt;br /&gt;&lt;br /&gt;        PersonBAL3 pBAL = new PersonBAL3();&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            pBAL.Delete(personID);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            lblMessage.Text = "Record Deleted Successfully.";&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (Exception ee)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            lblMessage.Text = ee.Message.ToString();&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        finally&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            pBAL = null;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        GridView1.EditIndex = -1;&lt;br /&gt;&lt;br /&gt;        // Refresh the list&lt;br /&gt;&lt;br /&gt;        BindGrid();&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Above method will fire when Delete link will be clicked on the GridView. In the above code, I am instantiating PersonBAL3 and calling Delete method by passing personID as parameter so that select reocrds will be deleted from datbase. &lt;br /&gt;&lt;br /&gt;Code to Update records &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Hide Code&lt;br /&gt;&lt;br /&gt;protected void UpdateRecord(object sender, GridViewUpdateEventArgs e)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        int personID = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());&lt;br /&gt;&lt;br /&gt;        int intResult = 0;&lt;br /&gt;&lt;br /&gt;        GridViewRow row = GridView1.Rows[e.RowIndex];&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        TextBox tFN = (TextBox) row.FindControl("txtFName");&lt;br /&gt;&lt;br /&gt;        TextBox tLN = (TextBox)row.FindControl("txtLName");&lt;br /&gt;&lt;br /&gt;        TextBox tAge = (TextBox)row.FindControl("txtAge");&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        // instantiate BAL&lt;br /&gt;&lt;br /&gt;        PersonBAL3 pBAL = new PersonBAL3();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        try&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            intResult = pBAL.Update(personID, tFN.Text, tLN.Text, int.Parse(tAge.Text));&lt;br /&gt;&lt;br /&gt;            if (intResult &gt; 0)&lt;br /&gt;&lt;br /&gt;                lblMessage.Text = "Record Updated Successfully.";&lt;br /&gt;&lt;br /&gt;            else&lt;br /&gt;&lt;br /&gt;                lblMessage.Text = "Record couldn't updated";&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        catch (Exception ee)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            lblMessage.Text = ee.Message.ToString();&lt;br /&gt;&lt;br /&gt;        }        finally&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            pBAL = null;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        GridView1.EditIndex = -1;&lt;br /&gt;&lt;br /&gt;        // Refresh the list&lt;br /&gt;&lt;br /&gt;        BindGrid();&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Above method will fire when Update link will be clicked for a particular row of the GridView in edit mode. In the above method, I am instantiating PersonBAL3 and calling the Update method by p[assing required parameters. &lt;br /&gt;&lt;br /&gt;Now we have all set to go, now just run your project and try inserting records. You can also navigate to another page your created (list.aspx) and try updating, deleting records. &lt;br /&gt;&lt;br /&gt;Conclusion &lt;br /&gt;&lt;br /&gt;By using 3-Tier architecture in your project you can achive &lt;br /&gt;&lt;br /&gt;1. Seperation - the functionality is seperated from the data access and presentation so that it is more maintainable &lt;br /&gt;2. Independence - layers are established so that if one is modified (to some extent) it will not affect other layers. &lt;br /&gt;3. Reusability - As the layers are seperated, it can exist as a module that can be reused by other application by referencing it.&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5744050552898314142?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5744050552898314142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/3-tier-architecture-in-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5744050552898314142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5744050552898314142'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/3-tier-architecture-in-net.html' title='3-Tier architecture in .Net'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5862722237572634760</id><published>2009-05-11T02:27:00.001-07:00</published><updated>2009-05-11T02:27:45.363-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Check password strength in javascipt'/><title type='text'>Check password strength in javascipt</title><content type='html'>function passwordStrength(password)&lt;br /&gt;&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;        var desc = new Array();&lt;br /&gt;&lt;br /&gt;        desc[0] = "Very Weak";&lt;br /&gt;&lt;br /&gt;        desc[1] = "Weak";&lt;br /&gt;&lt;br /&gt;        desc[2] = "Better";&lt;br /&gt;&lt;br /&gt;        desc[3] = "Medium";&lt;br /&gt;&lt;br /&gt;        desc[4] = "Strong";&lt;br /&gt;&lt;br /&gt;        desc[5] = "Strongest";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        var score   = 0;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        //if password bigger than 6 give 1 point&lt;br /&gt;&lt;br /&gt;        if (password.length &gt; 6) score++;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        //if password has both lower and uppercase characters give 1 point      &lt;br /&gt;&lt;br /&gt;        if ( ( password.match(/[a-z]/) ) &amp;&amp; ( password.match(/[A-Z]/) ) ) score++;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        //if password has at least one number give 1 point&lt;br /&gt;&lt;br /&gt;        if (password.match(/\d+/)) score++;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        //if password has at least one special caracther give 1 point&lt;br /&gt;&lt;br /&gt;        if ( password.match(/.[!,@,#,$,%,^,&amp;,*,?,_,~,-,(,)]/) ) score++;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        //if password bigger than 12 give another 1 point&lt;br /&gt;&lt;br /&gt;        if (password.length &gt; 12) score++;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;         document.getElementById("passwordDescription").innerHTML = desc[score];&lt;br /&gt;&lt;br /&gt;         document.getElementById("passwordStrength").className = "strength" + score;&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;form method="post" action="" id="user_registration" name="user_registration"&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;&lt;h1&gt;Password strength metter&lt;/h1&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;     &lt;br /&gt;&lt;br /&gt;                &lt;label for="user"&gt;Username&lt;/label&gt;&lt;input type="text" name="user" id="user"/&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;     &lt;br /&gt;&lt;br /&gt;                &lt;label for="name"&gt;Name&lt;/label&gt;&lt;input type="text" name="name" id="name"/&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;     &lt;br /&gt;&lt;br /&gt;                &lt;label for="surname"&gt;Surname&lt;/label&gt;&lt;input type="text" name="surname" id="surname"/&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;     &lt;br /&gt;&lt;br /&gt;                &lt;label for="email"&gt;E-mail&lt;/label&gt;&lt;input type="text" name="email" id="email"/&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;     &lt;br /&gt;&lt;br /&gt;                        &lt;label for="pass"&gt;Password&lt;/label&gt;&lt;input type="password" name="pass" id="pass" onkeyup="passwordStrength(this.value)" /&gt;&lt;br /&gt;&lt;br /&gt;                         &lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;     &lt;br /&gt;&lt;br /&gt;                &lt;label for="pass2"&gt;Confirm Password&lt;/label&gt;&lt;input type="password" name="pass2" id="pass2"/&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;label for="passwordStrength"&gt;Password strength&lt;/label&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;div id="passwordDescription"&gt;Password not entered&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;                        &lt;div id="passwordStrength" class="strength0"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;                &lt;p&gt;     &lt;br /&gt;&lt;br /&gt;                &lt;input type="submit" name="submit" id="submit" value="Register"&gt;&lt;br /&gt;&lt;br /&gt;                &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/form&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5862722237572634760?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5862722237572634760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/check-password-strength-in-javascipt.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5862722237572634760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5862722237572634760'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/check-password-strength-in-javascipt.html' title='Check password strength in javascipt'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-4200870952936950647</id><published>2009-05-11T00:21:00.000-07:00</published><updated>2009-05-11T00:22:31.137-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='FTP File Upload using FtpWebRequest in .Net C#'/><title type='text'>FTP File Upload using FtpWebRequest in .Net C#</title><content type='html'>public void ftpfile(string ftpfilepath, string inputfilepath)   &lt;br /&gt;{   &lt;br /&gt;    string ftphost = "127.0.0.1";   &lt;br /&gt;    //here correct hostname or IP of the ftp server to be given   &lt;br /&gt;  &lt;br /&gt;    string ftpfullpath = "ftp://" + ftphost + ftpfilepath;   &lt;br /&gt;    FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);   &lt;br /&gt;    ftp.Credentials = new NetworkCredential("userid", "password");   &lt;br /&gt;    //userid and password for the ftp server to given   &lt;br /&gt;  &lt;br /&gt;    ftp.KeepAlive = true;   &lt;br /&gt;    ftp.UseBinary = true;   &lt;br /&gt;    ftp.Method = WebRequestMethods.Ftp.UploadFile;   &lt;br /&gt;    FileStream fs = File.OpenRead(inputfilepath);   &lt;br /&gt;    byte[] buffer = new byte[fs.Length];   &lt;br /&gt;    fs.Read(buffer, 0, buffer.Length);   &lt;br /&gt;    fs.Close();   &lt;br /&gt;    Stream ftpstream = ftp.GetRequestStream();   &lt;br /&gt;    ftpstream.Write(buffer, 0, buffer.Length);   &lt;br /&gt;    ftpstream.Close();   &lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-4200870952936950647?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/4200870952936950647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/ftp-file-upload-using-ftpwebrequest-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4200870952936950647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/4200870952936950647'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/ftp-file-upload-using-ftpwebrequest-in.html' title='FTP File Upload using FtpWebRequest in .Net C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2431243932973599059</id><published>2009-05-11T00:13:00.000-07:00</published><updated>2009-05-11T00:14:23.397-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Split String in C#'/><title type='text'>Split String in C#</title><content type='html'>public static string[] SplitString()&lt;br /&gt;        {&lt;br /&gt;            string str="|name;87,156|new_ic1;28,239|new_ic2;31,239,156|new_ic3;34,239|new_ic4;38,239|new_ic5;41,239.....|";&lt;br /&gt;&lt;br /&gt;            // char[] array for the separators&lt;br /&gt;            char[] separators =  new char[] {'|', ',', ';', '.'};&lt;br /&gt;&lt;br /&gt;            // string[] array to store splitted valus&lt;br /&gt;&lt;br /&gt;            string[] values= new string[7];&lt;br /&gt;&lt;br /&gt;            values = str.Split(separators);&lt;br /&gt;&lt;br /&gt;            return values;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2431243932973599059?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2431243932973599059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/split-string-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2431243932973599059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2431243932973599059'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/split-string-in-c.html' title='Split String in C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-3400667094243083988</id><published>2009-05-08T04:57:00.001-07:00</published><updated>2009-05-08T04:57:54.253-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP.Net'/><title type='text'>How to Set Focus to Web Form Controls By Using Client-Side Script?</title><content type='html'>&lt;script language="javascript"&gt;&lt;br /&gt;function SetFocus()&lt;br /&gt;{&lt;br /&gt;     // W3C approved DOM code that will work in all modern browsers     &lt;br /&gt;     if (document.getElementById)&lt;br /&gt;          document.getElementById('txt2').focus();&lt;br /&gt;     else&lt;br /&gt;     // To support older versions of IE:&lt;br /&gt;     if (document.all)&lt;br /&gt;          document.all("txt2").focus();&lt;br /&gt;     return false;&lt;br /&gt;}&lt;br /&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-3400667094243083988?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/3400667094243083988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-set-focus-to-web-form-controls.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3400667094243083988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/3400667094243083988'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/how-to-set-focus-to-web-form-controls.html' title='How to Set Focus to Web Form Controls By Using Client-Side Script?'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8698908046948106924</id><published>2009-05-07T22:20:00.000-07:00</published><updated>2009-05-07T22:24:05.057-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Word document C#'/><title type='text'>Add Header and Footer in Word document</title><content type='html'>&lt;strong&gt;Header:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;foreach (Word.Section section in this.Application.ActiveDocument.Sections)&lt;br /&gt;{&lt;br /&gt;    object fieldEmpty = Word.WdFieldType.wdFieldEmpty;&lt;br /&gt;    object autoText = "AUTOTEXT  \"Page X of Y\" ";&lt;br /&gt;    object preserveFormatting = true;&lt;br /&gt;&lt;br /&gt;    section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Fields.Add(&lt;br /&gt;        section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range,&lt;br /&gt;        ref fieldEmpty, ref autoText, ref preserveFormatting);&lt;br /&gt;    section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]&lt;br /&gt;        .Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Footer:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Word.Document document = this.Application.ActiveDocument;&lt;br /&gt;foreach (Word.Section wordSection in document.Sections)&lt;br /&gt;{&lt;br /&gt;    wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]&lt;br /&gt;        .Range.Font.ColorIndex = Word.WdColorIndex.wdDarkRed;&lt;br /&gt;&lt;br /&gt;    wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]&lt;br /&gt;        .Range.Font.Size = 20;&lt;br /&gt;    wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary]&lt;br /&gt;        .Range.Text = "Confidential";&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8698908046948106924?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8698908046948106924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/add-header-and-footer-in-word-document.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8698908046948106924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8698908046948106924'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/add-header-and-footer-in-word-document.html' title='Add Header and Footer in Word document'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-1613232229820931781</id><published>2009-05-06T05:35:00.000-07:00</published><updated>2009-05-06T05:37:04.976-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Display data in GridView from Excel Sheet'/><title type='text'>Display data in GridView from Excel Sheet</title><content type='html'>OleDbConnection DBConnection = new&lt;br /&gt;     OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=...;" + "Extended&lt;br /&gt;     Properties=\"Excel 8.0;HDR=Yes\"");&lt;br /&gt;  DBConnection.Open();&lt;br /&gt;  string SQLString = "SELECT * FROM [Sheet1$]";&lt;br /&gt;  OleDbCommand DBCommand = new OleDbCommand(SQLString, DBConnection);&lt;br /&gt;  IDataReader DBReader = DBCommand.ExecuteReader();&lt;br /&gt;  GridView1.DataSource = DBReader;&lt;br /&gt;  GridView1.DataBind();&lt;br /&gt;  DBReader.Close();&lt;br /&gt;  DBConnection.Close();&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-1613232229820931781?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/1613232229820931781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/display-data-in-gridview-from-excel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1613232229820931781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1613232229820931781'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/display-data-in-gridview-from-excel.html' title='Display data in GridView from Excel Sheet'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5347721854793774690</id><published>2009-05-06T05:14:00.000-07:00</published><updated>2009-05-06T05:15:33.350-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Render DataTable to Excel'/><title type='text'>Rendering the underlying DataTable to Excel</title><content type='html'>protected void RenderDataTableToExcel_Click(object sender, EventArgs e)&lt;br /&gt;&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        DataTable dt = GetData();&lt;br /&gt;&lt;br /&gt;        string attachment = "attachment; filename=Employee.xls";&lt;br /&gt;&lt;br /&gt;        Response.ClearContent();&lt;br /&gt;&lt;br /&gt;        Response.AddHeader("content-disposition", attachment);&lt;br /&gt;&lt;br /&gt;        Response.ContentType = "application/vnd.ms-excel";&lt;br /&gt;&lt;br /&gt;        string tab = "";&lt;br /&gt;&lt;br /&gt;        foreach (DataColumn dc in dt.Columns)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            Response.Write(tab + dc.ColumnName);&lt;br /&gt;&lt;br /&gt;            tab = "\t";&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        Response.Write("\n");&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;        int i;&lt;br /&gt;&lt;br /&gt;        foreach (DataRow dr in dt.Rows)&lt;br /&gt;&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;            tab = "";&lt;br /&gt;&lt;br /&gt;            for (i = 0; i &lt; dt.Columns.Count; i++)&lt;br /&gt;&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                Response.Write(tab + dr[i].ToString());&lt;br /&gt;&lt;br /&gt;                tab = "\t";&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            Response.Write("\n");&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        Response.End();&lt;br /&gt;&lt;br /&gt;    }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5347721854793774690?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5347721854793774690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/rendering-underlying-datatable-to-excel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5347721854793774690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5347721854793774690'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/rendering-underlying-datatable-to-excel.html' title='Rendering the underlying DataTable to Excel'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-1985585562960051794</id><published>2009-05-05T22:27:00.000-07:00</published><updated>2009-05-05T22:28:37.640-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Javascript'/><title type='text'>AllowOnlyNumeric() function in Javascript</title><content type='html'>// JavaScript Function&lt;br /&gt;function AllowOnlyNumeric()&lt;br /&gt;{&lt;br /&gt;    // Get the ASCII value of the key that the user entered&lt;br /&gt;    var key = window.event.keyCode;&lt;br /&gt;    // Verify if the key entered was a numeric character (0-9) or a decimal (.)&lt;br /&gt;    if ( (key &gt; 47 &amp;&amp; key &lt; 58) || key == 46 )&lt;br /&gt;        // If it was, then allow the entry to continue&lt;br /&gt;        return;&lt;br /&gt;    else&lt;br /&gt;        // If it was not, then dispose the key and continue with entry&lt;br /&gt;        window.event.returnValue = null; &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// HTML Code&lt;br /&gt;&lt;input type="text" name="[ControlName]" onkeypress="AllowOnlyNumeric()" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-1985585562960051794?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/1985585562960051794/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/allowonlynumeric-function-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1985585562960051794'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1985585562960051794'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/allowonlynumeric-function-in-javascript.html' title='AllowOnlyNumeric() function in Javascript'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5248352699986945634</id><published>2009-05-05T04:59:00.000-07:00</published><updated>2009-05-05T05:00:34.899-07:00</updated><title type='text'>Use web config for connection string</title><content type='html'>&lt;strong&gt;WebConfig:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;connectionStrings&gt;&lt;br /&gt;       &lt;add name="MainConnStr" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|main.mdf;User Instance=true" providerName="System.Data.SqlClient"/&gt;&lt;br /&gt;&lt;/connectionStrings&gt;&lt;br /&gt;&lt;strong&gt;&lt;br /&gt;Code Behind:&lt;/strong&gt;&lt;br /&gt;string connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5248352699986945634?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5248352699986945634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/use-web-config-for-connection-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5248352699986945634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5248352699986945634'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/use-web-config-for-connection-string.html' title='Use web config for connection string'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-2888913261828764330</id><published>2009-05-05T04:56:00.000-07:00</published><updated>2009-05-05T04:58:46.713-07:00</updated><title type='text'>DataSet export to Excel</title><content type='html'>private void createDataInExcel(DataSet ds)&lt;br /&gt;{&lt;br /&gt;          Application oXL;&lt;br /&gt;          _Workbook oWB;&lt;br /&gt;          _Worksheet oSheet;&lt;br /&gt;          Range oRng;&lt;br /&gt;          string strCurrentDir = Server.MapPath(".") + "\\reports\\";&lt;br /&gt;          try&lt;br /&gt;          {&lt;br /&gt;                   oXL = new Application();&lt;br /&gt;                   oXL.Visible = false;&lt;br /&gt;                   //Get a new workbook.&lt;br /&gt;                   oWB = (_Workbook)(oXL.Workbooks.Add( Missing.Value ));&lt;br /&gt;                   oSheet = (_Worksheet)oWB.ActiveSheet;&lt;br /&gt;                   //System.Data.DataTable dtGridData=ds.Tables[0];&lt;br /&gt;                   int iRow =2;&lt;br /&gt;                   if(ds.Tables[0].Rows.Count&gt;0)&lt;br /&gt;                   {&lt;br /&gt;                                 for(int j=0;j&lt;ds.Tables[0].Columns.Count;j++)&lt;br /&gt;                                  {&lt;br /&gt;                                  oSheet.Cells[1,j+1]=ds.Tables[0].Columns[j].ColumnName;&lt;br /&gt;                             &lt;br /&gt;                             for(int j=0;j&lt;ds.Tables[0].Columns.Count;j++)&lt;br /&gt;                             {&lt;br /&gt;                                      oSheet.Cells[1,j+1]=ds.Tables[0].Columns[j].ColumnName;&lt;br /&gt;                             }&lt;br /&gt;                             // For each row, print the values of each column.&lt;br /&gt;                             for(int rowNo=0;rowNo&lt;ds.Tables[0].Rows.Count;rowNo++)&lt;br /&gt;                             {&lt;br /&gt;                                      for(int colNo=0;colNo&lt;ds.Tables[0].Columns.Count;colNo++)&lt;br /&gt;                                      {&lt;br /&gt;                                                                    oSheet.Cells[iRow,colNo+1]=ds.Tables[0].Rows[rowNo][colNo].ToString();&lt;br /&gt;                                      }&lt;br /&gt;                             }&lt;br /&gt;                             iRow++;&lt;br /&gt;                   }&lt;br /&gt;                   oRng = oSheet.get_Range("A1", "IV1");&lt;br /&gt;                   oRng.EntireColumn.AutoFit();&lt;br /&gt;                   oXL.Visible = false;&lt;br /&gt;                   oXL.UserControl = false;&lt;br /&gt;                   string strFile ="report"+ DateTime.Now.Ticks.ToString() +".xls";//+&lt;br /&gt;                   oWB.SaveAs( strCurrentDir +                strFile,XlFileFormat.xlWorkbookNormal,null,null,false,false,XlSaveAsAccessMode.xlShared,false,false,null,null);&lt;br /&gt;                   // Need all following code to clean up and remove all references!!!&lt;br /&gt;                   oWB.Close(null,null,null);&lt;br /&gt;                   oXL.Workbooks.Close();&lt;br /&gt;                   oXL.Quit();&lt;br /&gt;                   Marshal.ReleaseComObject (oRng);&lt;br /&gt;                   Marshal.ReleaseComObject (oXL);&lt;br /&gt;                   Marshal.ReleaseComObject (oSheet);&lt;br /&gt;                   Marshal.ReleaseComObject (oWB);&lt;br /&gt;                   string  strMachineName = Request.ServerVariables["SERVER_NAME"];&lt;br /&gt;                   Response.Redirect("http://" + strMachineName +"/"+"ViewNorthWindSample/reports/"+strFile);&lt;br /&gt;          }&lt;br /&gt;          catch( Exception theException )&lt;br /&gt;          {&lt;br /&gt;                   Response.Write(theException.Message);&lt;br /&gt;          }&lt;br /&gt;}&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-2888913261828764330?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/2888913261828764330/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/dataset-export-to-excel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2888913261828764330'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/2888913261828764330'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/dataset-export-to-excel.html' title='DataSet export to Excel'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8406478785778605808</id><published>2009-05-05T04:49:00.000-07:00</published><updated>2009-05-05T04:50:38.847-07:00</updated><title type='text'>Web address validations in Javascript with Regex</title><content type='html'>public static bool IsUrl(string Url)     {         string strRegex = "^(https?://)"         + "?(([0-9a-z_!~*'().&amp;amp;=+$%-]+: )?[0-9a-z_!~*'().&amp;amp;=+$%-]+@)?" //user@         + @"(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP- 199.194.52.184         + "" // allows either IP or domain         + @"([0-9a-z_!~*'()-]+\.)*" // tertiary domain(s)- www.         + @"([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // second level domain         + "[a-z]{2,6})" // first level domain- .com or .museum         + "(:[0-9]{1,4})?" // port number- :80         + "((/?)" // a slash isn't required if there is no file name         + "(/[0-9a-z_!~*'().;?:@&amp;amp;=+$,%#-]+)+/?)$";         Regex re = new Regex(strRegex);&lt;br /&gt;        if (re.IsMatch(Url))             return (true);         else             return (false);     }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8406478785778605808?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8406478785778605808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/web-address-validations-in-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8406478785778605808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8406478785778605808'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/web-address-validations-in-javascript.html' title='Web address validations in Javascript with Regex'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-1550036707504561558</id><published>2009-05-05T04:48:00.000-07:00</published><updated>2009-05-05T04:49:30.086-07:00</updated><title type='text'>Open remote URL in Maximize window</title><content type='html'>public static void mOpenFile(string URL)&lt;br /&gt;        {&lt;br /&gt;       &lt;br /&gt;        Screen scr = Screen.PrimaryScreen;&lt;br /&gt;        int oldWidth = scr.Bounds.Width;&lt;br /&gt;        int oldHeight = scr.Bounds.Height;&lt;br /&gt;        Process proc = new Process();&lt;br /&gt;        proc.StartInfo.FileName = URL; // put full path in here&lt;br /&gt;        proc.StartInfo.WindowStyle =ProcessWindowStyle.Maximized;&lt;br /&gt;        proc.Start();       &lt;br /&gt;      proc.Dispose();&lt;br /&gt;        }&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-1550036707504561558?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/1550036707504561558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/open-remote-url-in-maximize-window.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1550036707504561558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/1550036707504561558'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/open-remote-url-in-maximize-window.html' title='Open remote URL in Maximize window'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-8580124154926309141</id><published>2009-05-05T04:46:00.000-07:00</published><updated>2009-05-05T04:47:50.897-07:00</updated><title type='text'>Application base path of executable</title><content type='html'>&lt;p&gt;public static stringGetPath()&lt;br /&gt;        {&lt;/p&gt;&lt;p&gt;return System.AppDomain.CurrentDomain.BaseDirectory.ToString();&lt;br /&gt;        }&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-8580124154926309141?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/8580124154926309141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/application-base-path-of-executable.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8580124154926309141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/8580124154926309141'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/application-base-path-of-executable.html' title='Application base path of executable'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-988976672169234786.post-5071623715803698324</id><published>2009-05-05T04:39:00.000-07:00</published><updated>2009-05-05T04:43:51.960-07:00</updated><title type='text'>Anonymous Methods in C#</title><content type='html'>protected void DemoForm_Load(object sender, EventArgs e)&lt;br /&gt;{   &lt;br /&gt;List customerList = new List();  &lt;br /&gt; customerList.Add(new Customer(00004, "kabir"));   &lt;br /&gt;customerList.Add(new Customer(00005, "Krishan"));   &lt;br /&gt;customerList.Add(new Customer(00006, "Karan"));   &lt;br /&gt;customerList.Sort(          delegate(Customer lhs, Customer rhs)&lt;br /&gt; {            &lt;br /&gt;return lhs.CustomerID.CompareTo(rhs.CustomerID);            &lt;br /&gt;//OR return rhs.CustomerID.CompareTo(lhs.CustomerID);        &lt;br /&gt; });     //one can use customerList.Reverse() to reverse the sort order   &lt;br /&gt; foreach (Customer customer in customerList)        &lt;br /&gt;Response.Write(customer.CustomerID+"");&lt;br /&gt;}&lt;br /&gt;public class Customer&lt;br /&gt;{   &lt;br /&gt;private int m_CustomerID        = int.MinValue;   &lt;br /&gt;private string m_CustomerName   = string.Empty;  &lt;br /&gt; public Customer(int customerId,string customerName)   &lt;br /&gt; {    &lt;br /&gt;  this.m_CustomerID = customerId;      &lt;br /&gt;this.m_CustomerName = customerName;   &lt;br /&gt;}   &lt;br /&gt;public int CustomerID    &lt;br /&gt;{       &lt;br /&gt;get { return m_CustomerID;&lt;br /&gt;}     &lt;br /&gt; set&lt;br /&gt; {&lt;br /&gt;m_CustomerID = value;&lt;br /&gt;}   &lt;br /&gt;}   &lt;br /&gt;public string CustomerName  &lt;br /&gt; {    &lt;br /&gt;  get&lt;br /&gt;{&lt;br /&gt;return m_CustomerName;&lt;br /&gt;}      &lt;br /&gt;set&lt;br /&gt;{&lt;br /&gt;m_CustomerName = value;&lt;br /&gt;}  &lt;br /&gt; }&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/988976672169234786-5071623715803698324?l=kalit-codesnippetsofnettechnology.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://kalit-codesnippetsofnettechnology.blogspot.com/feeds/5071623715803698324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/anonymous-methods-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5071623715803698324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/988976672169234786/posts/default/5071623715803698324'/><link rel='alternate' type='text/html' href='http://kalit-codesnippetsofnettechnology.blogspot.com/2009/05/anonymous-methods-in-c.html' title='Anonymous Methods in C#'/><author><name>kalit</name><uri>http://www.blogger.com/profile/06926361249526760368</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://1.bp.blogspot.com/_zpFefy31Gkc/SYKUiboDxmI/AAAAAAAAAAM/jjnmmi0D6m8/S220/NetSet.JPG'/></author><thr:total>0</thr:total></entry></feed>
