only My site

Saturday, June 21, 2008

C# Code Snippets


Page Control Iteration
=======================



How many TextBoxes would you like to create? (Please choose vaule between 1 and 10)


MinimumValue="1" MaximumValue="10" Type="Integer"
ErrorMessage="Make sure that you choose a value between 1 and 10!" />


OnClick="CreateTextBoxes" />






***************************************************
Splitting the string into array using delimiter - ToCharArray()
===================================================
string = "\r\n";
char[] splitter = string.ToCharArray();
***************************************************
DBnULL IN DATA ROW
===================
dr.IsNull("Doctype1") ? Convert.ToInt32(dr["Doctype1"]) : 0;

***************************************************
REF:
====
LoadData( ref dsNotify );

protected void LoadData(ref DataSet dsAuthors)
{


}
***********************************************************

***********************************************************

***********************************************************

***********************************************************

Javascript : Using Math functions

function Multiply()
{//No of Hrs / No. of retry = Retry frequency
//Eg: 39 / 10 = 3.9 which is equal to 4 Hrs and 30 Mins
var var1,var2,var3;
var intHrs;
var intMins;
var1 = parseFloat(document.getElementById("txtop1").value );
var2 = parseFloat(document.getElementById("txtop2").value);
if ( isNaN(var1) isNaN(var2) )
{
var3 = 0;
document.getElementById("txtop3").value = "0:00" ;

return true;
}
var3 = var2 / var1;
intHrs = Math.floor(var3);
if (var3 - intHrs > 0.59)
{
intMins = (var3 - intHrs) - 0.60;
intHrs += 1;
}
else
{
intMins = var3 - intHrs;
}
intMins = intMins.toFixed(2) * 100;
document.getElementById("txtop3").value = intHrs + ":" + intMins ;
return true;
}



Add Dataset table using Reader

// connection and query details
String connect = "your-connection-string";
const String SQL = "SELECT TOP 5 OrderID, OrderDate, ShipName, ShipCity, "
+ "ShipCountry FROM [Orders];"
+ "SELECT TOP 5 * FROM [Order Details];"
+ "SELECT TOP 5 CustomerID, CompanyName, Address, City, "
+ "Country FROM [Customers]";

// create a connection, command and get a DataReader
using (SqlConnection con = new SqlConnection(connect))
{
SqlCommand cmd = new SqlCommand(SQL, con);
con.Open();
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);

// create an array of table names for first two incoming rowsets
String[] tablenames = new String[] {"Orders", "Order Details"};

// load the data from the DataReader
// no existing data, but have to provide a value for LoadOptions
// so use OverwriteRow - makes no difference in this case
DataSet ds = new DataSet();
ds.Load(reader, LoadOption.OverwriteRow, tablenames);

// load another table directly using the Load method
DataTable dt = new DataTable();
dt.TableName = "Customers";
dt.Load(reader);
ds.Tables.Add(dt);

// display the results
...
}

Visual Studio 2008 - Tips & Issues

Visual studio : 1
When paste a code in aspx file, the designer will not get updated until there is no error in the aspx .Eg: the pasted code have the same Id as of the current page then it will not update this control id and rest of the ids in the pasted code.
Visual studio : 2
"Clean Solution" - The Solution Explorer in Visual Studio 2005 now makes it easy for you to clean up unwanted files. Simply choose Clean Solution from the Build Menu and all the intermediate files and output directories in your whole solution will be removed. This is a quicker and easier way to perform the same cleanup as you could in the command line environment with the following syntax:
devenv /clean SolnConfigName SolutionName
http://msdn.microsoft.com/en-us/vs2005/aa718635.aspx

DVD Player s/w

I tried AVS DVD player and its cool. Its totally free..

Tuesday, June 10, 2008

Quotes of the Day












Paint.Net


I tried this Free tool, its pretty good to do photo editing works.
To Download http://www.getpaint.net/