protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { if (Request.QueryString["pcod"] == null) { TabContainer1.Tabs[1].Enabled = false; TabContainer1.Tabs[2].Enabled = false; } else { ViewState["cod"] = Request.QueryString["pcod"]; bind(); bind1(); nsuncarte.clsprd obj = new nsuncarte.clsprd(); List <nsuncarte.clsprdprp> k = obj.fnd_rec(Convert.ToInt32 (Request.QueryString["pcod"])); TextBox1.Text = k[0].prdtit; TextBox2.Text = k[0].prdreldat.ToShortDateString(); TextBox3.Text = k[0].prdmrkprc.ToString(); TextBox7.Text = k[0].prddsc; DropDownList1.DataBind(); DropDownList1.SelectedIndex = -1; nsuncarte.clssubcat obj1 = new nsuncarte.clssubcat(); List <nsuncarte.clssubcatprp> k1 = obj1.fnd_rec(k[0].prdsubcatcod); DropDownList1.Items.FindByValue(k1[0].subcatcatcod.ToString()).Selected = true; DropDownList2.DataBind(); DropDownList2.SelectedIndex = -1; DropDownList2.Items.FindByValue(k[0].prdsubcatcod.ToString()).Selected = true; Button1.Text = "Update"; } TabContainer1.ActiveTabIndex = 0; } }
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { nsuncarte.clssubcat obj = new nsuncarte.clssubcat(); List <nsuncarte.clssubcatprp> x = obj.fnd_rec(Convert.ToInt32(GridView1.DataKeys[e.NewEditIndex][0])); DropDownList1.SelectedIndex = -1; DropDownList1.Items.FindByValue(x[0].subcatcatcod.ToString()).Selected = true; TextBox1.Text = x[0].subcatnam; ViewState["cod"] = x[0].subcatcod; Button1.Text = "Update"; e.Cancel = true; }