原程式網頁的網頁點我
但如果是連動例如DropDownList1連動DropDownList2就必需要用jquery live(邊學邊做系列有教大家可以去看看)
好像要jQuery 1.3.2版後才有這功能喔
////// 判斷是否為數字 /// /// 傳入判斷的字串。 public static bool IsNumeric(String pNumber) { Regex NumberPattern = new Regex("[^0-9.-]"); return !NumberPattern.IsMatch(pNumber); } ////// 三位一撇 + 小數??位 /// /// 傳入字串數字。 /// 傳入字串。 public static string ToThree(string pInt,string p0) { string mReturn = string.Empty; if (pInt != "") { if (IsNumeric(pInt)) { mReturn = string.Format("{0:N"+ p0+"}", Convert.ToDecimal(pInt)); } } else { mReturn = string.Format("{0:N" + p0 + "}", "0"); } return mReturn; }
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('完成');opener.location.reload();window.close();", true);
protected void Button1_Click(object sender, EventArgs e) { Response.Clear(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); //內容自行新增 string fileName = DropDownList1.SelectedValue.ToString() + DropDownList1.SelectedValue.ToString()+ ".xls"; if (Request.Browser.Browser == "IE") { fileName = Server.UrlPathEncode(fileName); } string style = " "; Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName ); //Response.Write(""); Response.ContentType = "application/ms-excel"; Response.ContentEncoding = System.Text.Encoding.Default;//.Unicode;//.UTF8;// System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); //文字格式處理 Response.Write(style); Response.Write(sb.ToString());//內容 Response.Write(stringWrite.ToString()); Response.End(); } 以下這段一定要加 public override void VerifyRenderingInServerForm(Control control) { //處理'GridView' 的控制項 'GridView' 必須置於有 runat=server 的表單標記之中 }ps如放在button放在updatepanel裡
update StatementList set CX_Less_Money = (CX_Total - ( select SUM( CONVERT(Decimal, CX_Amount ) ) from StatementItem where ID_Statement=@ID_Statement)) where ID_Statement =@ID_Statement