| 
                
                    |   | 如何實現英文字母以區分大小寫的形式排序?如aa AA bb BB 應排序為 AA BB aa bb? | 觀看回應 |  
                    |  | 方法: 1. 在SqlServer中,字元類型的欄位元都可以設定定序,更改此欄位的定序為二進位編碼排序,這樣order by field就會按照你說的規則,大寫在上,小寫在下。
 2. 或者...order by ...,ascii(abc),...,但ascii只針對abc之第一位。
 
 
 
 
 
 |  |  
 | 
		| 
                
                    |   | 如何在WebGridView自行帶值的方法。 | 觀看回應 |  
                    |  | 可以利用RowDataBound的事件來設定欄位的初值, 如下: protected void WebGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
 //做Default操作(Insert時使用)
 if (e.Row.RowType == DataControlRowType.Footer && WebGridView1.ShowFooter)
 {
 Control ctrl = e.Row.FindControl("TextBox1");
 if (ctrl != null && ctrl is TextBox)
 {
 TextBox txt = (TextBox)ctrl;
 txt.Text = "abc";
 }
 }
 //做Default操作(Update時使用)
 if (e.Row.RowType == DataControlRowType.DataRow)
 {
 Control ctrl = e.Row.FindControl("TextBox1");
 if (ctrl != null && ctrl is TextBox)
 {
 TextBox txt = (TextBox)ctrl;
 txt.Text = "abc";
 }
 }
 }
 
 
 
 
 
 |  |  
 | 
		| 
                
                    |   | WebFormView如何用程式控制自行帶值的方法? | 觀看回應 |  
                    |  | 可以使用FormView的DataBound事件來完成,如下: protected void wfvMaster_DataBound(object sender, EventArgs e)
 {
 if (wfvMaster.CurrentMode == FormViewMode.Insert) // Insert才做
 {
 WebRefVal ctrl = (WebRefVal)wfvMaster.FindControl("WebRefVal1"); //假設名稱為WebRefVal1
 ctrl.BindingValue = "001"; //設為001
 WebDateTimePicker ctrl1 = (WebDateTimePicker) wfvMaster.FindControl ("WebDateTimePicker1");
 ctrl1.Text = System.DateTime.Now.ToShortDateString();//如果DateTime型態
 ctrl1.DateString = System.DateTime.Now.ToString("yyyyMMdd"); //如果為VarChar(8)型態.
 }
 }
 
 
 
 
 
 |  |  
 | 
		| 
                
                    |   | 在Navigator按下更改時,要預設的欄位值,也寫在哪個Event? | 觀看回應 |  
                    |  | 為了集中在Navigator中管理,須配合將InfoBindingSource.AutoDisibleControl=True,這樣User才不會任意直接去TextBox中來編輯資料,錯過了Navigator按下Edit的時機,因此就可以將這個功能做在Navigator的AfterItemClick事件中,把更改後的預設值寫進InfoBindingSource,如下: if (e.ItemName == "Edit")
 {
 infoTextBox1.Text= “測試”;
 }
 
 
 
 
 |  |  
 | 
		| 
                
                    |   | 我想在WebNavigator按下新增時,WebFormView有個label會直接帶入登入者的姓名? | 觀看回應 |  
                    |  | 可在WebFormView的DataBound的事件中寫入,程式如下: protected void WebFormView1_DataBound(object sender, EventArgs e)
 {
 if (WebFormView1.CurrentMode == FormViewMode.Insert)
 {
 Label KeyinNameLabel = (Label)WebFormView1.FindControl("KeyinNameLabel");//KeyinNameLabel為該Label的ID
 KeyinNameLabel.Text = CliUtils.fUserName;
 }
 }
 
 
 
 
 
 |  |  
 |