Tuesday, January 11, 2011

in my radgrid i use template as EditFormType. When I open the edit form for a grid item I want to show or hide a texbos based on the value populated in it. It can be achieved this way:

Protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
TextBox TextBox1 = (TextBox)item.FindControl("TextBox1");
//OR/// TextBox txtbox = (TextBox)item["TextBox1"].Controls[0];
if (TextBox1.Text == "your value")
{
TextBox1.Visible = false;
}
}
}

Friday, January 07, 2011

radwindow pops up all the time unexpected

I use the following line in code behind to open a radwindow:




During as soon as I opened the window once, any postback will cause this window to popup again.

The solution is simple, just put the following code into page_load event.
RadWindow1.Visible = false;

Wednesday, November 17, 2010

open radwindow using radmenu item click within a template column of radgrid

first, make sure you have "ClientDataKeyNames="Id" " added into the Master Table View of the radgrid

then implement the following javascript:

function OpenRecordBreakdown(Id)
{
var oWnd = radopen("RecordBreakDown.aspx?Id=" + , "rwRecordBreakDown");
oWnd.setSize(900, 600);
oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Maximize + Telerik.Web.UI.WindowBehaviors.Resize + Telerik.Web.UI.WindowBehaviors.Close)
oWnd.Center();
}


var lastClickedItem = null;
var clickCalledAfterRadprompt = false;
var clickCalledAfterRadconfirm = false;
function onClientButtonClicking(sender, args) {

if (args.get_item().get_text() == "Delete") {
if (!clickCalledAfterRadconfirm) {
args.set_cancel(true);
lastClickedItem = args.get_item();
radconfirm("Are you sure you want to delete this Item?", confirmCallbackFunction);
}
}

if (args.get_item().get_text() == "Record Breakdown") {
var cell = sender.get_element().parentNode.parentNode;
rowindex = cell.rowIndex; //The row index may vary based on the grid structure.
var grid = $find("<%=rgList.ClientID %>");
var MasterTable = grid.get_masterTableView();
var id = MasterTable.get_dataItems()[rowindex - 2].getDataKeyValue("Id");

OpenRecordBreakdown(id);

args.set_cancel(true);
}
}

function confirmCallbackFunction(args) {
if (args) {
clickCalledAfterRadconfirm = true;
lastClickedItem.click();
}
else
clickCalledAfterRadconfirm = false;
lastClickedItem = null;
}

Thursday, November 11, 2010

Using radprompt and radconfirm with Telerik navigational controls

Found this article very useful, hope it can help you as well

Using radprompt and radconfirm with Telerik navigational controls

http://www.telerik.com/support/kb/aspnet-ajax/window/using-radprompt-and-radconfirm-with-telerik-navigational-controls.aspx

Wednesday, November 10, 2010

open radwindow in codebehind by radcombobox selectedindexchanged event

ScriptManager.RegisterStartupScript(this, typeof(abc_def_1), "openWin", "openWin('" + ParameterId.ToString() + "');", true);

provide you still need the radwindow manager in .aspx code, and the javascript "openWin"

Monday, October 18, 2010

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEve

"Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation."

in my case it is caused by trying to call a radgrid.rebind() in page_load, the radgrid sits inside of a radupdatepanel. In case of postback the code contains client script which caused this security breach. After I put radgrid.rebind() inside !IsPostBack the error disappearred.

Thursday, September 09, 2010

Persist RadGrid Settings

found this class really helpful:
http://www.telerik.com/help/aspnet-ajax/grdsavingsettingsonperuserbasis.html

Tuesday, August 03, 2010

Friday, July 16, 2010

visual studio 2010 issue referencing usercontrol property from container page

When I tried to reference a public property in user control from a container page, the intellisense doesn't seem to be able to pick up the property. Ignore the red curly underline, build the parent page, it worked~

another VS2010 bug?

Tuesday, June 29, 2010

find column value when updating RadGrid item using EditItemTemplate

if (e.CommandName == RadGrid.UpdateCommandName)
{
GridEditableItem editable = e.Item as GridEditableItem;
int TheId= Convert.ToInt32(editable.OwnerTableView.DataKeyValues[editable.ItemIndex]["TheId"].ToString());

Wednesday, May 05, 2010

asp.net logout user

FormsAuthentication.Signout();

Response.Resirect([loginURL]);

Friday, April 23, 2010

T-SQL loop through all rows in a table to add an incremental value

DECLARE @tempTable table(Id INT NOT NULL PRIMARY KEY)
DECLARE @counter INT
INSERT INTO @tempTable SELECT UserId from TestTable
SET @counter = 1
WHILE (@counter < (SELECT COUNT(UserId) FROM @tempTable)+1)
BEGIN
UPDATE TestTable SET TestColumn = '' WHERE Id = (
SELECT a.Id FROM
(SELECT Id, Row_Number() OVER(ORDER BY UserId) AS 'RN' from TestTable) as a
where a.RN = @counter
)
SET @counter = @counter + 1
END

Wednesday, April 21, 2010

RadGrid wont expand after updated to Q1 2010

This is because the detail table is set to "visible=false" during the update process. Not all RadGrid controls in the application get this symptom, not sure why this happens. All you need to do is to change the setting to "visible = true"

Tuesday, April 20, 2010

T-SQL division

I came cross this this issue of failing to do a division with 2 integer values. Stupid enough......

so In order for the division to work i used CAST(value TO FLOAT)

Monday, April 19, 2010

Setup Radwindow on button in code behind

int tempId= 168;
RadWindow rw = rwmTEMP.Windows[0];
rw.Width = System.Web.UI.WebControls.Unit.Pixel(1000);
rw.Height = System.Web.UI.WebControls.Unit.Pixel(1000);
rw.Behaviors = WindowBehaviors.Move | WindowBehaviors.Close | WindowBehaviors.Maximize | WindowBehaviors.Resize;
rw.OpenerElementID = btnOpenWindow.ClientID;

rw.NavigateUrl = "~/xxxxx/abccc.aspx?TempId=" + tempId.ToString();

Thursday, April 01, 2010

add new line in ajaxToolkit:ConfirmButtonExtender's ConfirmText

use the combination of &,#,10, and ; to create a new line

Friday, February 26, 2010

mssql reset table identity

the following script resets the table identity seeding to 99, the next record will have identity of 100

DBCC CHECKIDENT ("[table name]", RESEED, 99);
GO

Friday, February 12, 2010

Monday, February 08, 2010

RadGrid Export Button does not work

if the buttons are located within a RadAjaxPanel or RadUpdatePanel the button must be registered for postback event. This can be done in aspx or code behind:
C#:
ScriptManager.GetCurrent(Page).RegisterPostBackControl(ExportCSVButton);
ASPX:

Thursday, February 04, 2010

sql how to replace the time value in datetime column

update Table1
SET StartDateTime = CONVERT(datetime,
CONVERT(VARCHAR(10),StartDateTime , 101)
+' '+CONVERT(VARCHAR,datepart(HH,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(MI,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(SS,NewStartTime))
+':'+CONVERT(VARCHAR,datepart(Ms,NewStartTime))
)

Wednesday, February 03, 2010

replace time in datetime value c#

I have 2 datetime values: StartDateTime ('11/01/2010 00:00:00') and NewStartTime('12/02/2010 09:30:00 AM'). I want to replace the time value in StartDateTime with the time value in NewStartTime. In order to achieve so I go:
DateTime NewStartDateTime = new DateTime(StartDateTime.Year, StartDateTime.Month, StartDateTime.Day, NewStartTime.Hour, NewStartTime.Minute, NewStartTime.Second);

System.Web.HttpException: Request is not available in this context

this is caused by using "Request["xxx"]"
a quick fix is to use "HttpContext.Current.Request" instead

Wednesday, January 13, 2010

sql replace substring with value from associated table

Update TableA
set ColumnA1 = (select a.ColumnA from
(
"SELECT" REPLACE("t.ColumnA1, t.ColumnA2", (select "ColumnB1 from TableA where ColumnB2= t.ColumnA2))
FROM TableA t
) a
where TableA.ColumnA2 = a.ColumnA2)
GO

Wednesday, December 16, 2009

RadMenu hide menu item from server side

RadMenu1.FindItemByText("RadMenuItem1").Visible = false;

Tuesday, December 15, 2009

determine whether radscheduler is in edit mode or insert mode

Edit Mode:
"if"(!RadScheduler1.StartEditingInAdvancedForm)

Insert Mode:
"if"(!RadScheduler1.StartInsertingInAdvancedForm)

Thursday, December 10, 2009

asp.net export to txt file receive error in IE when hosted in IIS6

code:

"Response".Clear();
"Response".AddHeader("content-disposition", "attachment;filename=" + FileName + ".txt");
"Response".Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
"Response".ContentType = "application/vnd.text";
"StringWriter" stringWrite = new StringWriter();
"HtmlTextWriter" htmlWrite = new HtmlTextWriter(stringWrite);
"Response".Write(strTXTFileBuilder.ToString());
"Response".End();

Error:
Internet Explorer cannot download file from .
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.

My Solution:
Take out the line "
"Response".Cache.SetCacheability(HttpCacheability.NoCache);"

Wednesday, December 09, 2009

sql check existance before insert

'if' not 'exists' (select .... from .... where ....)
Begin
'Insert' Into ....... (..., ..., ...) values (..., ..., ...,)
END

Thursday, December 03, 2009

rebind parent page control on radwindow close

in the Parent page add into the radwinow aspx code:

sas"<"telerik:radwindow id="rwpopup111" title="popup111" runat="server" behaviors="Close" onclientclose="OnClientClose" navigateurl="popup111.aspx">

also add javascript:

function OnClientClose(oWnd)
{
//place your code to execute, see below for my examples, in this example I rebind a grid:
var hf111 = document.getElementById("");


var masterTable1 = $find("").get_masterTableView();
masterTable1.rebind();

var masterTable = $find("").get_masterTableView();
masterTable.rebind();
//after radwindow close you may lose title of the parent page, if that is the case reset it here:
document.title="abc";

}

Wednesday, October 28, 2009

RadWindow set size and more behaviors from code behind

rw.Width = Unit.Pixel(800);
rw.Height = Unit.Pixel(600);
rw.Behaviors = WindowBehaviors.Move & WindowBehaviors.Maximize & WindowBehaviors.Close;

SQL Server Reporting Services » how to add brackets around a value

question:

1. add brackets around a value

2. display or hide a string depending on a value. e.g. show "IDExists" in a textbox if Fields!ID != null, otherwise hide it

solution:

1. ="MemberID: (" & Fields!ID.Value &")"

2. =IIF (IsNothing(Fields!Id.Value), "","IdExist")

Friday, October 23, 2009

radwindow close window from code behind

http://www.telerik.com/help/aspnet/window/postbackandcloseonreload.html

Thursday, October 15, 2009

cater for sql apostrophe select condition in C#

Filter.Value = "LastName LIKE '" + tbLastNameFilter.Text.Trim().Replace("'", "''") + "%'";

Tuesday, October 13, 2009

How to remove duplicate rows from a table in SQL Server

http://support.microsoft.com/kb/139444

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine

http://blog.crowe.co.nz/archive/2007/04/16/728.aspx

http://geekswithblogs.net/wpeck/archive/2009/04/30/quotthe-microsoft.jet.oledb.4.0-provider-is-not-registered-on-the-local-machine.quot.aspx


http://www.telerik.com/support/kb/aspnet-ajax/general/error-on-64-bit-windows-machines-the-microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine.aspx

Turn Off “Saving Auto Recovery information” in Microsoft SQL Server Management Studio 2008

http://blog-mstechnology.blogspot.com/2009/06/turn-off-saving-auto-recovery.html

All Sample Connection String for All database using C#.Net and VB.Net

found this one useful

http://www.dotnetspider.com/resources/28823-All-Sample-Connection-String-for-All-database.aspx

Saturday, October 10, 2009

Saturday, October 03, 2009

datagridview checkbox column unable to fetch current row check status

need to use "datagridview1.EndEdit()" in "datagridview1_CellContentClick" event to finalize the editing of current row so that the changes made to the current row (in this case the change of check status) is submitted

Wednesday, September 30, 2009

oledbconnection problem "Unrecognized escape sequence....."

cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\ temp\\abc.mdb;User Id=admin;Password=;");
or
cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\ abc.mdb;User Id=admin;Password=;");

Sunday, September 27, 2009

Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine --------- dev error on vista x64 machine

this is because the driver is not x64. Solution: in project properties --> Build, select x86 in Platform Target

what's the status of a form after form1.show() and form1.hide() - Visual Studio 2008 Windows Form Application

in windows form application you can use Application.OpenForms collection to find the forms opened

Thursday, September 24, 2009

TSQL check if a view exists before create it

IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'vw_abc')
DROP VIEW [dbo].[vw_abc]

Thursday, August 06, 2009

Monday, August 03, 2009

C# ASP.NET use StringBuilder to export a txt file


StringBuilder strAAA = new StringBuilder();
foreach (DataRow drABC in datatableDEF.Rows)
{
strAAA.Append(drABC["xxxxx"]);
strAAA.Append(drABC[" "]);
strAAA.Append(drDEF["yyyyy"]);
strAAA.Append(drABC[" "]);
strAAA.Append(drGHI["zzzzzz"]);
strAAA.Append(drABC[" "]);
}

//end current line and start a new line
strAAA.AppendLine();
Response.AddHeader("content-disposition", "attachment;filename=ABC.txt"); Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.text"; StringWriter stringWrite = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); Response.Write(strAAA.ToString()); Response.End();

Thursday, July 30, 2009

sql get date within a datetime value

SELECT CONVERT(VARCHAR(10),GETDATE(),111)

--> returns 2009/07/30

SELECT CONVERT(VARCHAR(4),GETDATE(),111)
--> returns 2009

Friday, July 24, 2009

RadGrid allocate checkbox control within detailtable


the master table row must be expanded to open the detailtable before the value of the control can be accessed:



Monday, July 06, 2009

lost designer.aspx in asp.net web application

to fix it, right click on the aspx page in solution explorer and select Convert to Web Application"

RadGrid: rebind detailtable after command execution

e.Item.OwnerTableView.Rebind();

this only rebinds the detailtable, so the current expanding status will remain.

Friday, July 03, 2009

fetch the record primary key from MasterTable while using FormTemplate for insert and update

when you have a FormTemplate for insert and update in RadGrid.MasterTable, there is no commangArgument, therefore the record's primary key can not be passed on using commandargument.


This can be done by

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "Update")
{
int RecordId= Convert.ToInt32(RadGrid1.MasterTableView.DataKeyValues[e.Item.ItemIndex]["RecordId"].ToString());
}
}

Thursday, July 02, 2009

RadGrid: rebind detailtable from external event

protected void ReBindExpandedDetailTable()
{
foreach (GridDataItem item in RadGrid1.Items)
{
string aaaValueString= item.GetDataKeyValue("aaa").ToString();

if (aaaValueString== )
{
if (item.Expanded == true)
{
GridTableView nestedView = ((GridDataItem)item).ChildItem.NestedTableViews[0];
nestedView.Rebind();
}
}
}
}

RadGrid: hide add new and refresh buttons from code behind

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridCommandItem)
{
GridCommandItem cmditm = (GridCommandItem)e.Item;
//to hide AddNewRecord button
cmditm.FindControl("InitInsertButton").Visible = false;//hide the text
cmditm.FindControl("AddNewRecordButton").Visible = false;//hide the image

//to hide Refresh button
cmditm.FindControl("RefreshButton").Visible = false;//hide the text
cmditm.FindControl("RebindGridButton").Visible = false;//hide the image


}
}

RadGrid: problem displaying bool value in formtemplate type edit form insert mode

I was able to update any records in the grid. However when I clicked on Add New Record, I received an error "specified cast is not valid" on the boolean field "IsActive".

see code below for my ASPX page content


The solution is:

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{


if (e.CommandName == RadGrid.InitInsertCommandName)
{
GridEditCommandColumn editColumn = (GridEditCommandColumn)rgQualificationList.MasterTableView.GetColumn("EditCommandColumn");
editColumn.Visible = false;

e.Canceled = true;
//Prepare an IDictionary with the predefined values
System.Collections.Specialized.ListDictionary newValues = new System.Collections.Specialized.ListDictionary();

//set initial checked state for the checkbox on init insert
newValues["IsActive"] = false;

//Insert the item and rebind
e.Item.OwnerTableView.InsertItem(newValues);
}

Wednesday, July 01, 2009

Display RadGrid row details in AjaxToolkit ModalPopupExtender

found this code library useful
http://www.telerik.com/community/code-library/aspnet-ajax/grid/display-radgrid-row-details-in-ajaxtoolkit-modalpopupextender.aspx

Thursday, June 18, 2009

show or hide nested table views RadGrid SP1 Q1 2009

protected void ShowOrHideNestedTableView()
{
foreach (GridDataItem CS in rgABC.Items)
{

if (CS.OwnerTableView.Name == "AAA")
{
if (cb123.Checked)
{
CS.Parent.Visible = true;
CS.Visible = true;
}
else
{
CS.Parent.Visible = false;
CS.Visible = false;
}
}

}
}

protected void rgScheduleList_PreRender(object sender, EventArgs e)
{
ShowOrHideNestedTableView();
}

Wednesday, June 17, 2009

aspx c# open new window in button click event when the button is placed inside an ajax update panel

val1 is an integer
val2 is a boolean

System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("window.open(abc.aspx?val1=" + val1Value.ToString() + "');");
ScriptManager.RegisterClientScriptBlock(this.upd1, this.upd1.GetType(), "abc", sb.ToString(), true);

aspx passing on multiple parameter values in URL

val1 is an integer
val2 is a boolean


in page 1:

aspx:

c#:
RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("xxx('" + val1+ "',true);");

in page 2
c#
if (!string.IsNullOrEmpty(Request["val2"]))
{
if (bool.Parse(Request["val2"]))
----logic here---------
}


if (!string.IsNullOrEmpty(Request["val1"]))
{
if (int.Parse(Request["val1"])>0)
----logic here---------
}

Thursday, June 04, 2009

COALESCE

use COALESCE to manage a nullable db value, reference:
http://msdn.microsoft.com/en-us/library/ms190349.aspx

Monday, May 25, 2009

Error: Could not load file or assembly 'Telerik.Web.UI, Version=2009.1.402

Error: Could not load file or assembly 'Telerik.Web.UI, Version=2009.1.402.X, Culture=neutral, PublicKeyToken=XXXX' or one of its dependencies

Found some useful sources here:

This is the one helped me to solve my problem

Another one here

one more

Another one here Here

Friday, May 22, 2009

making radgrid filters case insensitive

GroupingSettings-CaseSensitive="false"

Friday, May 01, 2009

locate and hide BoundField in gridview asp.net c#



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToString(DataBinder.Eval(e.Row.DataItem, "ABC")) == "Text To Be Found")
e.Row.Visible = false;
}
}

Friday, April 17, 2009

RadGrid hide column in export

RadGrid1.MasterTableView.Columns.FindByUniqueName("ABC").Visible = false;

sorting problem - RadGrid GridTemplateColumn

my code that has problem sorting template columns:



the instruction says "the SortExpression value should match the data field you want to sort on (typically the field a control in the template is bound to)". I made sure this rule is applied but the problem remained. Then I removed the HeaderTemplate components, instead I added value to HeaderText property in the GridTemplateColumn level. This solved the problem, not sure why though.....

the new code looks like:
...........
.......

Wednesday, April 15, 2009

RadGrid Insert UserControl does not close automatically after insert

use the following code below, make sure the CommandName on the Insert Button on the UserControl is named "PerformInsert"
protected void ABC_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
{  
if (e.CommandName == "PerformInsert")  
{  
//make sure the insert user control closes automatically after inserted
e.Item.OwnerTableView.IsItemInserted = false;  
}

Tuesday, April 14, 2009

ASP.NET How to deal with the message: error connecting to undo manager of source file "........"

* Delete the .designer.cs file
* convert the .aspx or ascx file into a webapplication by right clicking on it

Checked=' < % # DataBinder.Eval( Container, "DataItem.Active" ) % >'

C# Convert String to Guid

Guid ProductID = new Guid(String)

Friday, April 03, 2009

pre-populate value into RadGrid Insert



protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.InitInsertCommandName)
{
//enter the code here
}
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormInsertItem && RadGrid1.MasterTableView.IsItemInserted)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
(insertItem["abc"].Controls[0] as TextBox).Text = "hello world";
}
}

Monday, February 16, 2009

Visual Studio 2005 bug in ASP.NET applications

my web.config has multiple connection strings.
when I right click on a table adapter in a dataset in design view, select "configure...", the dataset configuration window pops up. Naturally you'd just make the changes that you want to the query and click on Finish. If this table adapter doesn't use the first connection string listed in the web.config, visual studio will automatically change the connection string to the first one listed in the web.config.

In order to fix the problem when you first open up the configuration window click on Previous to go back to the connection string selection view, RESELECT the connection string. If you happened to encounter this error until this stage right click on the empty area of the dataset design view and select View Code. Then delete the unused connection string.

Wednesday, February 04, 2009

ipconfig not working in cmd mode - Vista issue

when i tried to enter ipconfig in cmd mode it says: not valid command.

the solution is: right click on the cmd program and select "run as administrator".

why couldn't Vista run my programs as administrator when i logged in as administrator? this is stupid!

Tuesday, December 23, 2008

Compare mobile phone Cap Plans

found this tool very useful
http://www.mobchoice.com.au/compare-cap-plans-spreadsheet

Wednesday, December 10, 2008

string.format new line partially works (C#, ASP.NET)

see below my code. every "\n" works fine except the ones after "Event: {0}" and "Start Date: {1:D}", basically the Event, Start Date and End Date are printed on same line. can anyone help please? thanks in advance.

string.Format(



"Schedule Details: \n" +

"Event: {0}\n"+


"Start Date: {1:D} \n" +

"End Date: {2:D} \n" +

"Location: {3} \n"


,schedule.event,
schedule.startDate,
schedule.endDate,
schedule.location);

I tried ""Event: {0}"+ Environment.NewLine" and "Event: {0}\r" and "Event: {0}/r/n" got the same result
==============

Schedule Details:

Event: Basketball Match Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009

Location: Como
================

Then I tried "Event: {0}\n"+ Environment.NewLine" and "Event: {0}\r"+ Environment.NewLine" and "Event: {0}/n/r" got this result (an additional line)
==============


Schedule Details:

Event: Basketball Match

Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009

Location: Como
================

It seems that it works either for no newline or 2 new lines, but not for 1 newline. I tried to take out "Event" everything else worked just fine, so the problem must be with "Event"?

The Event has datatype of "string", startDate and endDate are datetime, location is string. A sample of Event value is "Attend Class Certificate III in Basketball".

Eventually the problem is solved, not sure why though.....:

I put single quotes around the Event value, not sure how exactly but it worked.
"Event: '{0}'\n"+

Tuesday, August 05, 2008

select checkboxlist based on to database data

foreach(datarow in the query result)
{

ListItem currentCheckBox = CheckBoxListABC.Items.FindByValue(datarow ["TheFieldName"].ToString());
if (currentCheckBox != null)
{
currentCheckBox.Selected = true;
}
}

Monday, August 04, 2008

ASP.NET C# capitalize the first letter of a string

using System.Globalization;
..
..
..
..
..
string ManipulatedString= CultureInfo.CurrentCulture.TextInfo.ToTitleCase("OriginalString");

Saturday, August 02, 2008

"postback" event not related to REVIOUS and NEXT button on Internet Explorer?

in my case PageA has a buttonA that opens PageB. The code is "response.redirect("PageB.aspx");"

on PageB I have some methodM to call under condition "if (!IsPostBack)"

After I clicked on ButtoA to open PageB, methodM is trigerred.

but when I use the PREVIOUS button on Internet Explore to go back to PageA and click on NEXT button to go back to PageB the methodM didn't fire.

How can I catch the Previous and Next button click event?

the answer is adding the code below into Page_Load in the target page, this line of code will force the target page to load from server instead of cache

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Wednesday, July 30, 2008

a helpful tutorial for Creating a Data Access Layer in VS2005 Express

http://www.asp.net/learn/data-access/tutorial-01-cs.aspx

How to retrieve visitor's IP in C# ASP.NET 2.0

string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
return clientIPAddress;

Friday, July 25, 2008

MSSQL LIKE operator work with parameter values

without parameter: LIKE '%abc%'
with parameter: LIKE '%'+@searchString+'%'

Tuesday, June 17, 2008

useful stuff to solve visual studio 2008 slowness

found these links quite useful:
http://blogs.msdn.com/webdevtools/archive/2008/02/09/downloadable-hotfix-performance-and-editor-fixes-for-microsoft-visual-studio-2008-and-visual-web-developer-express-2008.aspx

https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10826

Tomorrow's CIO: Are You Ready Today?

found this tool on InformationWeek very interesting:
http://www.informationweek.com/news/management/interviews/showArticle.jhtml?articleID=208403497#sg_wrapper

Monday, June 09, 2008

Cannot open .zip file in WSS 3.0

found solution for this problem on Microsoft
http://support.microsoft.com/kb/841120

Thursday, June 05, 2008

WSS 3.0 Search Service on SBS

You need to install and start Windows Indexing service, start SharePoint Search Service, and Change the Identity of the SP website in IIS-->Application Pools-->Properties from Network User to Local System User

Monday, May 26, 2008

project management - agile

project management - agile
In order to be agile everyone in the team must be proficient.

Thursday, May 22, 2008

ASP.NET DataBinding Eval V.S. Bind

Eval is used for one way data presentation whereas Bind is used to push data back to the database. Some detailed explanation:

http://www.15seconds.com/issue/040630.htm

Wednesday, May 14, 2008

Agile Project Management with Scrum

found this about Scrum, very helpful

http://agilescrum.tar.hu/agile_scrum_0035.html

Monday, May 12, 2008

"check-in pending" problem opening enterprise project within MS Project 2007

work around:
1. delete cache OR
2. when close the project, don't just click on "x", instead go File - Close

Friday, May 09, 2008

Available fields in Microsoft Office Project 2007

Available fields in Microsoft Office Project 2007
http://office.microsoft.com/en-us/project/HA102369301033.aspx?pid=CH100788901033

Thursday, May 08, 2008

what is Queue in MSPS 2007

Microsoft Office Project Server 2007 Queuing System

http://technet.microsoft.com/en-us/library/cc197395.aspx

Wednesday, May 07, 2008

what is resource units in Microsoft Office Project 2007

Sometimes it takes one resource to complete a task, but other times you need more. Sometimes a resource can only work part time. To account for these differences, Microsoft Office Project 2007 uses units (units: The quantity of a resource assigned to a task. The maximum units is the maximum number of units available for the resource. For example, if you have three plumbers, the maximum units is 300 percent or three plumbers working full-time.) to calculate the exact amount of time resources can work on a task............
Details: http://office.microsoft.com/en-us/project/HA102548291033.aspx

Configuring Linked Servers SQL Server 7 and 2000

found this post very helpful
http://www.informit.com/articles/article.aspx?p=21644

Tuesday, May 06, 2008

Endnote x1 with WORD 2007 slows down Windows Vista x64

found a workaround for this issue
http://www.endnote.com/envista.asp

Tuesday, April 22, 2008

Walkthrough: Validating User Input in a Web Forms Page

found this article on MSDN very helpful
http://msdn2.microsoft.com/en-us/library/a0z2h4sw(VS.80).aspx
Visual Studio 2005, c#, web form, validator control

Wednesday, April 16, 2008

translate 'In' operator in SQL to LINQ

Just found out there is no 'In' in LINQ, instead there is an ANY in LINQ:
e.g.
var abc=
from d in mydb.department
where mydb.employee.Any(e => e.ProductID == d.ManagerId)
select d;

Tuesday, April 15, 2008

OUTKAST - PROTOTYPE



[Intro]
I hope that you're the one
If not, you are the prototype
We'll tiptoe to the sun
And do thangs I know you like

[Hook]
I think I'm in love again [repeat]

[Verse 1]
Today must be my lucky day
Baby, you are the prototype
Do sumn' outta the ordinary
Like catch a manitee
Baby you are the prototype
I think I'm..

[Hook]

[Verse 2]
If we happen to part
Lord knows I don't want that
But hey, we can't be mad at God
We met today for a reason
I think I'm on the right track now

[Hook]

The Scene
Come here

[Hook]

[Outro (ad libs)]
Girl, right now I wanna say, I wanna say
I wanna say stank you very much
For picking me up
And bringing me back to this world
I can't, I'm not
I can't afford to not record
I thank I wanna say
I thank I wanna say stank you, stank you
Smelly much!
For picking me up and bringing me back to this world
Hey, hey John! Are we recording our ad libs?
Really?? Were we recording just then?
Let me hear that, that first one
When I first started

Tuesday, April 01, 2008

不归路


歌曲:不归路

歌手:迪克牛仔

专辑:忘记我还是忘记他

词∶许常德 曲∶林进璋


我没有退路

尽管你也千辛万苦

不愿认输

是良心让爱坚固

剩下由老天做主

爱你是一条不归路

一度我非常孤独

但是我更怕漂浮

不知道身在何处

有时候绝路也是人生一条路

爱让人全意付出忘记有结束

一心只想你幸福

疏忽了自己痛苦

我没有退路

尽管你也千辛万苦

不愿认输

是良心让爱坚固

剩下由老天做主

有時候错误也是人生一条路

谁不是跌到谷底才有点觉悟

只要你不想退出

我不怕命运残酷

我没有退路

尽管你也千辛万苦

不愿认输

是良心让爱坚固

剩下由老天做主

我没有退路

尽管我也千辛万苦也不愿认输

是良心让爱坚固

老天做主

Monday, March 17, 2008

美丽的神话-成龙,金喜善

解开我 最神秘的等待 星星坠落 风在吹动
终于再将你拥入怀中 两颗心颤抖
相信我 不变的真心 千年等待 有我承诺
无论经过多少的寒冬 我绝不放手

이젠 나의 손을 잡고 눈을 감아요 yi jie na ye so nul qia go,nu nul ka ma yo.
(现在紧抓住我的手闭上眼睛)
우리 사랑했던 날들 생각해봐요 u li sa la hei dang nal dul,sei ga ke ba yo.
(请你回想起过去我们恋爱的日子)
우리 너무 사랑해서 아팠었네요 u li no mu sa la hei so,ha pa so ne yo.
(我们是因为太爱所以更使得我们痛苦)
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)

每一夜 被心痛穿越 思念永没有终点
早习惯了孤独相随 我微笑面对
相信我 已选择等待 再多苦痛也不闪躲
只有你的温柔能解救 无边的冷漠

이젠 나의 손을 잡고 눈을 감아요 yi jie na ye so nul qia go,nu nul ka ma yo.
(现在紧抓住我的手闭上眼睛)
우리 사랑했던 날들 생각해봐요 u li sa la hei dang nal dul,sei ga ke ba yo.
(请你回想起过去我们恋爱的日子)
우리 너무 사랑해서 아팠었네요 u li no mu sa la hei so,ha pa so ne yo.
(我们是因为太爱所以更使得我们痛苦)
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)

让爱成为你我心中 那永远盛开的花
穿越时空绝不低头 永不放弃的梦
우리 너무 사랑해서 아팠었네요 u li no mu sa la hei so,ha pa so ne yo.
(我们是因为太爱所以更使得我们痛苦)
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)

让爱成为你我心中 那永远盛开的花
우리 소중했던 약속 잊지는 말아요 u li so ju hei dang ya kso,yi ji ni ma la yo.
(我们千万不要忘记我们的约定)
唯有真爱追随你我 穿越无尽时空
서로 사랑한단 말도 못했었네요 so lo sa la ha dan mal do,mo tei so ne yo.
(我们连"爱你"这句话都无法讲)
爱是心中唯一不变美丽的神话

美丽的神话-孙楠,韩虹

梦中的人熟悉的脸孔
你是我守候的温柔
就算泪水淹没天地
我不会放手,每一刻孤独的承受
只因我曾许下承诺
你我之间熟悉的感动
爱就要苏醒
万世沧桑唯有爱是永远的神话
潮起潮落始终不悔真爱的相约
几番若痛的纠缠多少黑夜掐扎
紧握双手让我和你再也不离分
枕上雪冰封的爱恋
真心相摇篮才能融解
风中摇曳炉上的火
不灭亦不休
等待花开春去春又来
无情岁月笑我痴狂
心如钢铁任世界荒芜
思念永相随
悲欢负月唯有爱是永远的神话
谁都没有遗忘古老,古老的誓言
你的泪水化为漫天飞舞的彩蝶
爱是翼下之风两心相随自在飞
你就是我心中唯一美丽的神话

爱情诺曼底

六月六日六时六分刚过六十秒
脆弱的堡垒远眺如风化的沙雕
轻抚着断裂的皱纹沧桑一条条
谁的心早已死掉
曾和你相爱如天命难违的凑巧
为何与你对决变成轮回的纷扰
爱如那常消的海潮退去时飘渺
我的心不再计较
情爱它似毒药 你我早就应该知道
为何却不停的要
为何却一再的要
我怎么才能登上你的爱情诺曼底
别让天与海的距离 衡量爱与恨的对立
怎么才能让我登上你的爱情诺曼底
狂奔在破晓的大地 拼了命也要找到你
占领这爱情诺曼底 Yeah

Thursday, March 13, 2008

挑衅

我的梦早已归零 我的爱结成冰

退色的刺青 残留的姓名 那是我的曾经

别为我动了真情 别怪我那么ㄍㄧㄥ

孤独的背影 落寞的神情 经不起你的挑衅

不要闯进我冰冷的爱情 我怕沉睡的梦被你惊醒

无论束手就擒 或是抵挡你的入侵 都会让我 摇摆不定 触景伤情

你的梦如此清醒 你的爱太冷静

催泪的叮咛 温柔的神情 却又让我动心

别让我掉入陷阱 别恨我不敢听

固执的个性 坚定的表情 经不起你的挑衅

不要闯进我冰冷的爱情 我怕沉睡的梦被你惊醒

无论束手就擒 或是抵挡你的入侵 对我来说 都是挑衅

不要挑衅我冰冷的爱情 我怕醒来会爱你爱不停

请你别再靠近 不要让我恨不下心

现在的我 经不起你 一再挑衅