How to make div Center

How to make div Center: No need to use align= center because align is not supported by div Just take a dive and make its width 90% or as you want then use margin-left:auto; margin-right:auto; Consider we have following home.css file contains body { background-color:Gray; } #header { border-radius: 5px; margin-left:auto; margin-right:auto; background-color:Silver; width:80%; height:250px; […]

Selecting Record from XML Valued Column in MS SQL

Just Consider we have following records in a object named CR_NonDPC_ConfigDTO PCName : PC MotherBoard : ASROK 945 GCM Processor : Pantium HDD : HDD 160 GB RAM : DDR-2 1 GB Cassing : NULL ExtraConfig : CD ROM ASUS Now we shall convert it to XML (for converting Object to XML you can check […]

Executing *.sql file form C#

Sometimes we need to run *.sql script from our application for installing data base. SqlCommand is not right for running installation script because installation script consists of DDL and GO command. Here we use smo library for executing *.sql script. For doing above operation we need to add following references Microsoft.SqlServer.ConnectionInfo Microsoft.SqlServer.Smo Took me a […]

My Short Note

Use Session from Class Library (or Class Library Project) Add First we need to add System.Web as a reference on our project. System.Web.HttpContext.Current.Session[“MyVariable”]; System.Web.HttpContext.Current.Session(“MyVariable”); How to write connection string in web.config file At first we need to add following namespace using System.Collections.Generic; using System.Web.Configuration; Now use following code to write on web.config file Configuration […]

Clearing all TextBoxes text from a Form using C#

When we develop any application form, then there will be a new button where we need to perform clear operation. We can clear all the TextBox texts from a Form or a Control like panel, tabe pages using following code foreach (Control c in this.Controls) { if (c is TextBox) { c.Text = string.Empty; } […]

Run your Application without IIS. (using Cassini)

It is easy to run your web application without installing any web server. For running your application without IIS you have to use Cassini Desktop Adapter. Features of Cassini Desktop Adapter * Standalone Web Applications – now on the Desktop * 100% Embedded Web server * No Installation or GAC Required * No Administrator […]

Select Distinct Record from DataTable

If it is necessary to select distinct record from Data Table, then we can use following method. public DataTable SelectDistinct(DataTable SourceTable, string FieldName) { DataTable dt = new DataTable(); dt = SourceTable.Clone(); object LastValue = null; foreach (DataRow dr in SourceTable.Select(“”, FieldName)) { if (LastValue == null || !(ColumnEqual(LastValue, dr[FieldName]))) { LastValue = dr[FieldName]; dt.ImportRow(dr); […]

Converting List to DataTable in C#

There is no built in method for converting list to data table in C#. So we can implement following method for converting List to DataTable in C#. public DataTable ToDataTable(IList data) { PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(t)); DataTable table = new DataTable(); for (int i = 0; i < props.Count; i++) { PropertyDescriptor prop = props[i]; […]