Private: MY Note

Every thing you imagine, study it – know it – use it

ASP.NET Dynamic Data Preview #7: How Do I Use a DynamicControl in ListView and DetailsView Controls?

This video compares the same application written twice, once with Dynamic Data and once without. In the process, you add DynamicControl objects to ListView and DetailsView controls.

http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.dynamiccontrol.aspx

http://www.bestechvideos.com/2008/06/02/asp-net-dynamic-data-how-do-i-use-a-dynamiccontrol-in-listview-and-detailsview-controls

September 30, 2009 Posted by dev1 | .NET, .NET 2.0, ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

Sorting Generic List

//Sorting List<> case Item is ListItem
//==============================================
List<ListItem> tempList = new List<ListItem>();

tempList.Insert(0, new ListItem("------------- Vehicle Reports 8"));
tempList.Insert(0, new ListItem("------------- Vehicle Reports 2"));
tempList.Insert(0, new ListItem("------------- Vehicle Reports 4"));

// sort asc
tempList.Sort(delegate(ListItem p1, ListItem p2) {
                    return p1.Text.CompareTo(p2.Text);
                });
// sort desc
tempList.Sort(delegate(ListItem p1, ListItem p2) {
                    return p2.Text.CompareTo(p1.Text);
                });

//Sorting List<> case Item is Object Class
//===============================================
//Apply to sorting in GridView
//===============================================
SortData(e.SortExpression, NewSortDirection, ref listMsgTicker);
//===============================================

#region method for sorting

    private void SortData(string _expression, SortDirection _direction,
            ref List<MsgTicker> data)
    {
        //sort asc ==
        if (_direction == SortDirection.Ascending)
            data.Sort(delegate(MsgTicker a, MsgTicker b)
            {
                switch (_expression)
                {
                    case "MsgHeader": return a.MsgHeader.CompareTo(b.MsgHeader);
                    case "CreatedDate": return a.CreatedDate.CompareTo(b.CreatedDate);
                    case "ModifiedDate": return a.ModifiedDate.CompareTo(b.ModifiedDate);
                    default:
                        throw new NotImplementedException("Type of property not implemented yet");
                }
            });

        //sort desc ==
        if (_direction == SortDirection.Descending)
            data.Sort(delegate(MsgTicker a, MsgTicker b)
            {
                switch (_expression)
                {
                    case "MsgHeader": return b.MsgHeader.CompareTo(a.MsgHeader);
                    case "CreatedDate": return b.CreatedDate.CompareTo(a.CreatedDate);
                    case "ModifiedDate": return b.ModifiedDate.CompareTo(a.ModifiedDate);
                    default:
                        throw new NotImplementedException("Type of property not implemented yet");
                }
            });

        //return data;
    }

    #endregion
ref: http://dotnetslackers.com/Community/blogs/simoneb/archive/2007/06/20/How-to-sort-a-generic-List_3C00_T_3E00_.aspx

September 16, 2009 Posted by dev1 | .NET, .NET 2.0, AJAX, ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

ThaiBuddhistCalendar and DateTime Convertion

//date time utc
        DateTime _utc = DateTime.UtcNow;

        // utc --> thai
        ThaiBuddhistCalendar tbc = new ThaiBuddhistCalendar();

        int thaiDay = tbc.GetDayOfMonth(_utc);
        int thaiMonth = tbc.GetMonth(_utc);
        int thaiYearr = tbc.GetYear(_utc);

        string thaiDaate = thaiDay.ToString("00") + "/" + thaiMonth.ToString("00") + "/" + thaiYearr.ToString("0000");

        // thai --> utc
        DateTime _do, _UtcTime;
        DateTime.TryParseExact(thaiDaate, "dd/MM/yyyy", new CultureInfo("th-TH"), DateTimeStyles.None, out _do);
        _UtcTime = _do.ToUniversalTime();
ref: http://msdn.microsoft.com/en-us/library/system.globalization.thaibuddhistcalendar.getera.aspx

September 8, 2009 Posted by dev1 | .NET, .NET 2.0, ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

Convert DateTime Thai – Eng culture (Buddha – Christ Ex. year 2009 is 2552)

September 7, 2009 Posted by dev1 | .NET, .NET 2.0, ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

Tips to optimize design-time build performance for Web Sites in Visual Studio

There have been a number of posts with tips to improve build performance within Visual Studio 2005.  I’ve consolidate these posts and other tips into a single post of techniques for common problems.
ref: http://weblogs.asp.net/bradleyb/archive/2005/12/06/432441.aspx

September 5, 2009 Posted by dev1 | .NET, .NET 2.0, ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

Using LINQ with ASP.NET (Part 1)

One of the new things I’m super excited about right now is the LINQ family of technologies that are starting to come out (LINQ, DLINQ, XLINQ and others soon).

LINQ will be fully integrated with the next release of Visual Studio (code-name: Orcas) and it will include some very cool framework and tool support (including full intellisense and designer support).  Last week the LINQ team released the May CTP drop of LINQ that you can download from here.  What is cool about this CTP is that it works with VS 2005, and allows you to start learning more about it immediately.  It incorporates a bunch of customer feedback (for example: support for stored procedures in DLINQ), and also includes a built-in ASP.NET Web-Site Project to enable you to leverage it with ASP.NET apps (note: you can also use LINQ with the new VS 2005 Web Application Project option as well).

I’m going to put together a few blog postings over the next few weeks that show off ways to use LINQ/DLINQ/XLINQ within ASP.NET projects.  This first walkthrough below will help you get started and introduce some of the important LINQ concepts.  You can follow-along by downloading the May CTP LINQ preview above and typing in the code below (I list all of it below), or you can download and run the complete .zip file of my samples here (note: you still need to install the LINQ May CTP drop for the .zip file of samples to work). 

Note: LINQ, DLINQ and XLINQ will be fully supported in both C# and VB.  I am using C# for the example belows.

ref: http://weblogs.asp.net/scottgu/archive/2006/05/14/446412.aspx

September 5, 2009 Posted by dev1 | .NET, .NET 2.0, ASP.NET 3.5 | | No Comments Yet

Working with LINQ Using Visual Studio 2005

LINQ is the general-purpose standard query operator that allows traversal, filter and projection operations to be expressed in a direct yet declarative way in any .NET programming language.  The extensibility of the LINQ query language provides implementations that work over both XML and SQL data.  The query operator over XML is called XLINQ and the one over SQL is called DLINQ.  XLINQ is an efficient and in-memory XML facility to provide XPath/XQuery functionality.  DLINQ operator is for the integration of SQL based schema definitions into the CLR type System.        

LINQ will be fully integrated with the next release of the Visual Studio, which is named as Orcas now.  The best thing is that the LINQ can also be installed in Visual Studio 2005.  The May 2006 CTP release of LINQ is available and can be downloaded from this link.  Let us see how to create a new web site that uses LINQ features.

Ref: http://aspalliance.com/859

September 4, 2009 Posted by dev1 | .NET, .NET 2.0, ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

Handle resource files – Generate a class with strong typed properties using StronglyTypedResourceBuilder

Sample:

resgen D:\dev\myResources.resx d:\dev\Resources.resources /str:c#,Namespace1,myClass,d:\dev\MyFiles.cs

ref: http://www.c-sharpcorner.com/UploadFile/yougerthen/205232008052651AM/2.aspx

September 3, 2009 Posted by dev1 | .NET, ASP.NET 3.5 | | No Comments Yet

Generics List.FindAll (to filter)

June 15, 2009 Posted by dev1 | .NET, .NET 2.0, ASP.NET, ASP.NET 3.0 | | No Comments Yet

How do I convert an Enum value to a String?

January 27, 2009 Posted by dev1 | .NET | | 1 Comment