Wednesday, August 27, 2008

How To Get Month Name Form Date


Get Month Name From Given Date

SELECT DATENAME(MONTH,'08/15/1947')

sql server how to order by month,date


Order By Month

SELECT Emp_Name,CONVERT(varchar(11),DOB,113) as DOB FROM CV_DOB order By MONTH(DOB)


Order By Date

SELECT Emp_Name,CONVERT(varchar(11),DOB,113) as DOB FROM CV_DOB order By DAY(DOB)

Thursday, August 14, 2008

How To Remove Empty Rows In DataTable

int i = 0;
while (i <= datatableid.Rows.Count - 1)
{
if (datatableid.Rows[i]["ColumnName"].ToString().Trim() == string.Empty)
{
datatableid.Rows.RemoveAt(i);
}
else
{
i += 1;
}
}

Thursday, August 7, 2008

How To Count The Number Of Rows In The DataGrid

datagridname.Items.Count

Items

Gets a collection of DataGridItem objects that represent the individual items in the DataGrid control

How To Replace Null Value With The Custom Value

COALESCE ( expression [ ,...n ] )

Example :

SELECT COALESCE(FieldName,'0.00') FROM TableName;

If The Specified Field have null value it will be replace by 0.00 in the Result.

It's equivalent to Oracle NVL.

Friday, August 1, 2008

How To Set Max Length TextArea OnPaste


function maxLengthPaste(field,maxChars)
{
event.returnValue=false;
if((field.value.length + window.clipboardData.getData("Text").length) > maxChars)
{
return false;
}
event.returnValue=true;
}
Use OnPaste Went To Call This Function
onpaste="return maxLengthPaste(this,500)"


This Code Has Been Post By The Viewer As Comment