Posts

Dropdown value when EnableViewstate = false

If EnableViewstate of a dropdown is set to false, you would need to bind the data at every post. Nothing new in this! But, you might face issues in retrieving value selected in dropdown before postback. It will always be "" To get the value, pre-populate dropdown in Page_Init instead of Page_Load (if you are doing so). This will give the right selected value.

順著天賦做事,逆著個性做人

我是個很幸運的人,因為我經常遇到貴人,不管這些貴人們曾經如何對我,我總能直接或間接的從他們身上汲取到一些經驗! 對此,我也由衷的感謝! 當然,標題的這句話也是從貴人們身上獲得的寶貴經驗! 最近我常會想起這句話,"順著天賦做事,逆著個性做人",從字面上解釋,就是發揮自己的長才,修飾或隱藏自己在個性上的缺點,使得為人處事都能圓滿! 或許會有人說,那不就是偽裝? 虛偽? 其實不盡然。 舉例來說,我的專長就是溝通,所以,我就應該好好發揮這個長處,使得人、事、物得以透過溝通、協調進而圓滿! 這就是 "順著天賦做事"! 而我的個性其實很懶散,從小被管到大的我,很討厭被約束,我也很討厭去約束別人! 因為 "己所不欲,勿施於人"! 但,當我的工作付予任務,即時有千百個不願意,為了工作,為了群體利益,我就會壓抑著自己在個性上的特質,想辦法去完成任務! 這就是 "逆著個性做人"! 當然,有人曾經問我,"何苦來哉? 這樣對待自己能有什麼好處?" 剛開始我總會試著去說明,後來就只是笑著不回應了。乍看之下,這樣做的確對自己沒什麼好處,做得汗流浹背,別人嫌到口水亂噴! 我的理由如下: 對自己負責,也對工作有交待,心安理得。 如果事情能順利做完,也對群體有正面的助益,雖然知道會很苦,何不試著樂觀面對? 做起來也開心。 有些事,在當下會很苦、很難熬! 但,咬牙撑過後,反而會有一番不同的感受,結果,我又成長了。 過往的歷練也驗證了這句話的價值! 我因為這句話,受益不少! 至少,當別人在批評草莓世代時,我很慶幸自己的抗壓性在不同階段都能每況愈上! 只是我還是沒有做得很好! 至少,目前還是! 還需要多努力、多加油! 謹以此文引以為愓!

The power of Intel Quad core * 2 + FreeBSD 8 amd64

Image
因工作上的需求,我必須處理 Subversion 因為 svn blame 造成的高系統負載問題。 作業環境如下: FreeBSD 7.2 Apache 2.x Subversion 1.x viewvc 1.x 在原來的硬體環境: CPU: Intel Xeon 3.06 GHz with HT RAM: 2GB HDD: SCSI FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP/HT): APIC ID: 1 cpu2 (AP): APIC ID: 6 cpu3 (AP/HT): APIC ID: 7 一旦使用者透過 viewvc 執行 annotate 的工作,只要一個! 且單一檔案內容超過萬行的情況下,就會造成系統高負載 (average load 破百) 的情況,最嚴重的狀況是連 console 操作都會 hang 住! 而且 httpd 和 svn 的 process 數量也 fork 很多出來! 深究其因,應該是 viewvc 造成的! 其次,CPU 僅是透過 HT 虛擬成 4 個 cpu,而並非真正 multiple core,因此運算能力也相對較弱! 以提供服務的角度來看,這個功能是使用者經常用到的! 因此,除了去 trace viewvc 外,唯一可解的就是硬體升級了! 新的硬體環境: CPU: Intel Xeon E5420 2.5 GHz RAM: 48 GB HDD: SAS FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs FreeBSD/SMP: 2 package(s) x 4 core(s) cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 cpu2 (AP): APIC ID: 2 cpu3 (AP): APIC ID: 3 cpu4 (AP): APIC ID: 4 cpu5 (AP): APIC ID: 5 cpu6 (AP): APIC ID: 6 cpu7 (AP): APIC ID: 7 OS 改用 FreeBSD 8 amd64 的版本,將 /tmp 透過 md 掛載大小為 18G ...

Indexers in C# and VB.net

What are Indexers? Indexers allow instances of a class or struct to be indexed just like arrays. Indexers resemble properties except that their accessors take parameters. A class can have only one Indexer In VB.net, default keyword is required to make it indexer Index can be accessed either by a numeric index or even string How to Use (C#)? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CSconsole { class NamesList { public int Length { get { return objList.Count; } } List String > objList = new List string >(); public string this [ int index] { get { return objList[index]; } set { objList.Add ( value ); } } } public class TestIndexers { public static void Main () { ...

Convert nrg file to iso

There are 2 options on Debian/Linux: nrg2iso iat I tried nrg2iso at first, it told me the nrg file is already in ISO9660 format and did not covert. And I tried iat then that. It works fine! $ iat image.nrg image.iso Iso9660 Analyzer Tool v0.1.3 by Salvatore Santagati Licensed under GPL v2 or later Detect Signature ISO9660 START at 32768 Detect Signature ISO9660 END at 36864 Image offset start at 0 Sector header 0 bit Sector ECC 0 bit Block 2048 Done The outputed iso can be used with no wrong.

Handling Dropdownlist inside gridview

Often there is a need to handle OnSelectedIndexChanged event of a dropdown residing inside a GridView. This can be handled as following: 1. Specify an event handler from dropdown in ASPX < asp : GridView ID ="GridView1" runat ="server" AutoGenerateColumns ="False"> < Columns > < asp : TemplateField > < ItemTemplate > < asp : DropDownList OnSelectedIndexChanged ="ddl_Change" DataTextField ="UserName" AutoPostBack ="true" DataValueField ="userId" ID ="ddl" runat ="server"/> 2. Add event handler in ASPX.cs Protected Sub ddl_Change( ByVal sender As Object , ByVal e As EventArgs) 'You can retrieve Dropdown as: Dim DropDownControl As DropDownList = CType (sender, DropDownList) 'You can retrieve Parent GridRow as: Dim gridRow As GridViewRow = CType ( CType (sender, DropDownList).NamingContainer, GridViewRow) ...

Whats new in C# 2.0 3.0 4.0

What's new in C# 2.0 1. Generics 2. Nullable Types 3. Iterators 4. Partial Class Definitions 5. Anonymous Methods 6. The :: Alias Qualifier 7. Static Classes 8. Covariance and Contravariance 9. Fixed-Size Buffers 10. Friend Assemblies 11. extern Aliases 12. Method Group Conversion 13. Accessor Access Control 14. The #pragma Directive What's new in C# 3.0 1. Lambda expressions 2. Extension methods 3. Implicitly typed local variables 4. Query comprehensions 5. Anonymous types 6. Object initializers 7. Implicitly typed arrays 8. Automatic properties 9. Partial methods 10. Expression trees What's new in C# 4.0 1. Named and Optional Parameters 2. Dynamic Support 3. Variance 4. COM Interop