private void Bind() { if (Request["ID"] != null) { U_ZCBAOBU zcb1 = new U_ZCBAOBU(); DataSet ds = zcb1.GetZCBAOInfoByID(Request["ID"].ToString()); this.Bname.Text = ds.Tables[0].Rows[0]["Bname"].ToString(); this.Bjsf.Text = ds.Tables[0].Rows[0]["Bjsf"].ToString(); this.Bzeren.Text = ds.Tables[0].Rows[0]["Bzeren"].ToString(); this.Bzeren1.Text = ds.Tables[0].Rows[0]["bzeren1"].ToString(); this.Bremark.Text = ds.Tables[0].Rows[0]["Bremark"].ToString(); ViewState["Bname"] = ds.Tables[0].Rows[0]["Bname"].ToString(); string ids = zcb1.GetZCIDByBID(Request["ID"].ToString()); U_ZCBU zc1 = new U_ZCBU(); DataSet ds1 = zc1.GetZCInfoByID(ids); this.Repeater1.DataSource = ds1; this.Repeater1.DataBind(); zcb1.Close(); } }
private void SetPageData() { if (Request["id"] != null) { string id = Request["id"]; U_ZCBAOBU zcb1 = new U_ZCBAOBU(); DataSet ds = zcb1.GetZCBAOInfoByID(id); zcb1.Close(); //设置控件的值 bool owner = false; string user1 = ""; if (ds.Tables[0].Rows[0]["bzeren"] != DBNull.Value) { user1 = ds.Tables[0].Rows[0]["bzeren"].ToString(); } if (user1 == User.Identity.Name || (user1.Trim() == "" && Comm.IsRole("系统管理员"))) { owner = true; } else { this.Button1.Visible = false; } //设置控件数据的显示 for (int i = 1; i < ds.Tables[0].Columns.Count; i++) { string colName = ds.Tables[0].Columns[i].ColumnName.ToLower(); if (owner) { if (this.Bname.Parent.FindControl(colName) != null) { Util.SetControlValue(this.Bname.Parent.FindControl(colName), ds.Tables[0].Rows[0][colName]); } if (this.Bname.Parent.FindControl(colName + "_1") != null) { this.Bname.Parent.FindControl(colName + "_1").Visible = false;; } } else { if (this.Bname.Parent.FindControl(colName + "_1") != null) { Util.SetControlValue(this.Bname.Parent.FindControl(colName + "_1"), ds.Tables[0].Rows[0][colName]); } if (this.Bname.Parent.FindControl(colName) != null) { this.Bname.Parent.FindControl(colName).Visible = false;; } } } //设置数字金额的显示 string[] num1 = new string[] { "Bljsk", "Bljzc" }; for (int i = 0; i < num1.Length; i++) { TextBox t1 = this.Bljsk.Parent.FindControl(num1[i]) as TextBox; Label l1 = this.Bljsk.Parent.FindControl(num1[i] + "_1") as Label; if (t1 != null) { t1.Text = Comm.GetNumberFormat(t1.Text); } if (l1 != null) { l1.Text = Comm.GetNumberFormat(l1.Text); } } } }