Friday, April 17, 2009

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