protected void gv_DataBound(object sender, EventArgs e) { for (int i = 0; i < gv.Rows.Count; i++) { Label aa = (Label)gv.Rows[i].Cells[6].FindControl("Label3"); if (aa != null) { if (aa.Text.Trim().StartsWith("-")) aa.Text = "0"; int number; string hu = aa.Text.Trim(); int.TryParse(hu, out number); int num2 = int.Parse(DropDownList1.SelectedValue); int num3 = number * num2; gv.Rows[i].Cells[7].Text = num3.ToString(); } } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { SqlDataSource ses = new SqlDataSource(); ses.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["immis"].ConnectionString; ses.UpdateCommand = "update hi set total=@total where id=101"; ses.UpdateParameters.Add(new Parameter("total", TypeCode.String)); ses.UpdateParameters["total"].DefaultValue = DropDownList1.SelectedValue.ToString(); ses.Update(); }
3月 28, 2014
在GridView做加減並更新
標籤:
Asp.Net
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言