2012年12月8日 星期六

VB.NET 控制項變數名稱


   For i As Integer = 1 To 4
            CType(Me.Controls("label" & i), Label).Text = i
        Next

2012年12月4日 星期二

加總GridView內某欄位


dim  count as integer
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
'個人習慣將要加的欄位轉成template
 If e.Row.RowType = DataControlRowType.DataRow Then   
   dim countval as label = e.Row.FindControl("加總欄位id") 
   count += CType(countval.Text, Integer)
 elseIf e.Row.RowType = DataControlRowType.Footer Then
   e.Row.Cells(0).Text = "總分:"
   e.Row.Cells(1).Text = count  
 end if

end sub

DataTable的某個欄位作加總


DataTable dt = new DataTable();
string s_sum = dt .Compute("SUM(欄位名稱)", "").ToString();

取得 SqlDataSource 中Select 的結果做為DataSet 或 DataTable


取得 SqlDataSource 中Select 的結果做為DataSet 或 DataTable
'取得查詢結果
'使用DataView來取得sqlDataSource中 select 產生的結果
Dim dv As DataView = sqlDataSource1.Select(New DataSourceSelectArguments)



2012年11月30日 星期五

更改DataTable欄位名稱


DataBase如果回的資料是DataSet或是DataTable
而欄位資料與要Bind的的GridView不同
如果又不想要更改Bind這邊的欄位名稱
則可以直接更改DataTable的Cloumns


o_dt = Procedures.GetDataSet.Tables[0];
DataTable dt = o_dt;
dt.Columns["ACCT_TYPE_ID"].ColumnName = "ACCT_DATA";
dt.Columns["HIDACCT_TYPE_ID"].ColumnName = "ACCT_DATA2";

2012年11月15日 星期四

調整視窗大小 asp.net



    function resizeWindow()
{
//    var width = screen.availWidth;  // 螢幕可用寬度
//    var height = screen.availHeight;    // 螢幕可用長度
//    alert('最大化視窗大小:' + width + ' * ' + height);
//    moveTo(0,0);
//    resizeTo(width, height);
//  
 


2012年11月14日 星期三

textbox 提示效果


VB.NET

textbox.Attributes.Add("Value", "請輸入帳號")
textbox.Attributes.Add("OnFocus", "if(this.value=='請輸入帳號') {this.value=''}")
textbox.Attributes.Add("OnBlur", "if(this.value==''){this.value='請輸入帳號'}")


javascript

Attributes Even

OnFocus="javascript:if(this.value=='請輸入帳號') {this.value=''}"

OnBlur="javascript:if(this.value=='') {this.value='請輸入帳號'}"

----------------------------------------------------------------------------


OnFocus="javascript:if(this.value=='請輸入帳號') {this.value=''}"

OnBlur="javascript:if(this.value==''){this.value='請輸入帳號'}">