public void init() { GridView_Add.DataSource = null; GridView_Add.DataBind(); GridView1.DataSource = null; GridView1.DataBind(); GridView2.DataSource = null; GridView2.DataBind(); GridView3.DataSource = null; GridView3.DataBind(); }
protected void Btn_Add_Onclick(object sender, EventArgs e) { if (ViewState["Table"] != null) { dt = (DataTable)ViewState["Table"]; dt.Rows.Add(); GridView_Add.DataSource = dt; GridView_Add.DataBind(); } else { dt = new DataTable(); dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Barcode Number", typeof(int)), new DataColumn("Type", typeof(string)), new DataColumn("Cost Price", typeof(int)) }); dt.Rows.Add(1, "Jeans", 300); GridView_Add.DataSource = dt; GridView_Add.DataBind(); } }
//添加工单号,并追加各个gridview protected void add_wo_no_Click(object sender, EventArgs e) { DataTable table = GetGridViewData(); string wo_no = wo_no_1.Text; if (string.IsNullOrEmpty(wo_no)) { PageUtil.showToast(this, "请输入工单编号!"); return; } AnalogAcquisitionDC analogAcquisitionDC = new AnalogAcquisitionDC(); DataSet ds = analogAcquisitionDC.getSomeByWo_No(wo_no); DataSet ds3 = null; for (int i = 0; i < table.Rows.Count; i++) { if (string.Compare(wo_no, table.Rows[i][0].ToString()) == 0) { PageUtil.showToast(this, "工单号重复,请检查后输入"); return; } } if (ds == null || ds.Tables[0].Rows.Count == 0) { PageUtil.showToast(this, "该工单编号不存在!"); return; } else { //ds3 = analogAcquisitionDC.get_simulite_by_wo_no(wo_no); //if (ds3 == null || ds3.Tables[0].Rows.Count == 0) //{ // DateTime d = DateTime.Now; // int simulate_id=int.Parse(d.ToString("yyyyMMdd")); // int a = analogAcquisitionDC.add_wo_simulate(wo_no); // if (a == 0) // { // PageUtil.showToast(this.Page, "添加模拟单失败"); // return; // } // else // { // a = analogAcquisitionDC.update_wo_simulate(simulate_id, wo_no); // if (a == 0) // { // PageUtil.showToast(this.Page, "系统崩溃"); // return; // } // else // { // ds3 = analogAcquisitionDC.get_simulite_by_wo_no(wo_no); // } // } //} } Add_Wo_No(table, wo_no); GridView_Add.DataSource = table; GridView1.DataSource = addGridView1(ds); //GridView2.DataSource = addGridView2(ds3); GridView_Add.DataBind(); GridView1.DataBind(); //GridView2.DataBind(); wo_no_1.Text = ""; panl1.Style["display"] = "block"; panl2.Style["display"] = "none"; panl3.Style["display"] = "none"; string message = "更新完成"; status.InnerText = message; }