Thursday, April 28, 2011

Converting String To Type

Enum.Parse Method (Type, String)

http://msdn.microsoft.com/en-us/library/essfb559.aspx

Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object.

using System;
[Flags] enum Colors { None=0, Red = 1, Green = 2, Blue = 4 };
public class Example{
public static void Main()
{
string[] colorStrings = { "0", "2", "8", "blue", "Blue", "Yellow", "Red, Green" };
foreach (string colorString in colorStrings)
{
try {
Colors colorValue = (Colors) Enum.Parse(typeof(Colors), colorString);
if (Enum.IsDefined(typeof(Colors), colorValue) | colorValue.ToString().Contains(","))
Console.WriteLine("Converted '{0}' to {1}.", colorString, colorValue.ToString());
else
Console.WriteLine("{0} is not an underlying value of the Colors enumeration.", colorString);
}
catch (ArgumentException) {
Console.WriteLine("'{0}' is not a member of the Colors enumeration.", colorString);
}
}
}
}
// The example displays the following output:
// Converted '0' to None.
// Converted '2' to Green.
// 8 is not an underlying value of the Colors enumeration.
// 'blue' is not a member of the Colors enumeration.
// Converted 'Blue' to Blue.
// 'Yellow' is not a member of the Colors enumeration.
// Converted 'Red, Green' to Red, Green.

Tuesday, April 26, 2011

Database diagram support objects cannot be installed

"Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects."

Solution :
EXEC sp_dbcmptlevel 'yourDB', '90';
go
ALTER AUTHORIZATION ON DATABASE::yourDB TO "yourLogin"
go
use [yourDB]
go
EXECUTE AS USER = N'dbo' REVERT
go

Tuesday, February 22, 2011

Datalist Paging

Datalist Paging

public void BindList(){
PagedDataSource objPage = new PagedDataSource();


DataSet ds =new DataSet;
objPage.AllowPaging = true;
objPage.DataSource = ds.Tables["Gallery"].DefaultView;
objPage.PageSize = 8;

objPage.CurrentPageIndex = CurrentPage;

lbtnNext.Enabled = !objPage.IsLastPage;
lbtnPrev.Enabled = !objPage.IsFirstPage;


datalist1.DataSource = objPage;
datalist1.DataBind();
}
}

private void lbtnPrev_Click(object sender, System.EventArgs e)
{
CurrentPage -=1;
BindList();
}

private void lbtnNext_Click(object sender, System.EventArgs e)
{
CurrentPage +=1;
BindList();
}

Wednesday, July 28, 2010

VB.NET and C# Comparison

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
VB.NET and C# Comparison

Java and C# Comparison

http://www.harding.edu/fmccown/java_csharp_comparison.html
Java and C# Comparison

Tuesday, July 13, 2010

Automatic Redirect Page Using HTML

HEAD
META HTTP-EQUIV="refresh" CONTENT="5;URL=http://www.google.com/"
End HEAD
Your browser should automatically take you there in 5 seconds.
If it doesn't please go to http://www.google.com

Thursday, July 1, 2010

Getting Gridview Row Index in Row Command Event

GridViewRow rowSelect = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
int i = rowSelect.RowIndex;

OR

GridViewRow rowSelect = ((ImageButton)sender).Parent.Parent as GridViewRow;
int i = rowSelect.RowIndex;

OR

Bind in Button CommandArgument
((GridViewRow) Container).RowIndex

OR
GridView Row index by control
CheckBox chkBox = (CheckBox) sender;
GridViewRow gRow = (GridViewRow)chkBox.NamingContainer;

Monday, June 14, 2010

Export ASP.Net GridView to PDF and XLS using iTextSharp

http://www.aspsnippets.com/Articles/Export-ASP.Net-GridView-to-PDF-with-Custom-Columns-Widths-using-iTextSharp.aspx

http://sourceforge.net/projects/itextsharp/

Adding Custom Header in Gridview

protected void gViewEdit_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridView gView = (GridView)sender;
GridViewRow gViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell tblCell = new TableCell();
tblCell.Text = "Admission Report";
tblCell.ColumnSpan = 13;
tblCell.HorizontalAlign = HorizontalAlign.Center;
tblCell.Font.Size = 16;
tblCell.Font.Bold = true;
gViewRow.Cells.Add(tblCell);
gView.Controls[0].Controls.AddAt(0, gViewRow);
}
}

Wednesday, May 5, 2010

CheckBoxList Validator

An ASP.NET 2.0 Validator Web Control for CheckBoxes and CheckBoxLists
http://scottonwriting.net/sowblog/posts/10039.aspx

Wednesday, July 1, 2009

Can’t Play Flv files from Windows 2003 Server

Steps To Follow.

1. Open the site to configure in IIS. Right click and select "Properties"
2. Click the HTTP Headers Tab, select “File Types” under the MIME Map section, and then click "New Type". Enter the following:
1. Associated Extension box: .flv
2. MIME Type box: flv-application/octet-stream
3. Click "OK" and close the IIS Properties box
4. You may need to restart IIS( start->run->iisreset).

Tuesday, May 5, 2009

Rename MSSQL Server Database Name

ERROR: The database could not be exclusively locked to perform the operation.

SOLUTION:

ALTER DATABASE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
SP_RENAMEDB ,
Go
ALTER DATABASE SET MULTI_USER -- set back to multi user
GO

Monday, April 13, 2009

HDML

HDML - Handheld Device Markup Language
http://developer.openwave.com/dvl/tools_and_sdk/phone_simulator/choosing.htm

Image Gallery


http://www.outcut.de/MooFlow/MooFlow.html
http://net.tutsplus.com/articles/web-roundups/50-excellent-image-galleries-you-can-use-today/
http://jqueryfordesigners.com/slider-gallery/comment-page-8/

Wednesday, March 18, 2009

How to extend upload file Limit in PHP

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;


Goto
C:\wamp\bin\apache\Apache2.2.11\bin\php.ini
edit php.ini
Find upload_max_filesize
Change 2M to your maximum file upload size.

Tuesday, December 2, 2008

Crystal Reports for Visual Studio 2005

How to create Web or Windows applications in Crystal Reports for Visual Studio 2005.

http://msdn.microsoft.com/en-us/library/ms225270(VS.80).aspx