protected void grdvJl_RowDataBound(object sender, GridViewRowEventArgs e) { // Normal items if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || (e.Row.RowState == (DataControlRowState.Normal | DataControlRowState.Alternate)))) { DropDownList ddlFlange = (DropDownList)e.Row.FindControl("ddlFlange"); DropDownList ddlGasket = (DropDownList)e.Row.FindControl("ddlGasket"); if (ddlFlange.Items.Count <= 0) { ddlFlange.SelectedIndex = 0; ddlGasket.SelectedIndex = 0; } else { if (ddlFlange.SelectedValue != "") { try { WorkJunctionLiningFlangeGasketList workJunctionLiningFlangeGasketList = new WorkJunctionLiningFlangeGasketList(); workJunctionLiningFlangeGasketList.LoadAndAddItem(ddlFlange.SelectedValue, "", Int32.Parse(hdfCompanyId.Value)); ddlGasket.DataSource = workJunctionLiningFlangeGasketList.Table; ddlGasket.DataValueField = "Gasket"; ddlGasket.DataTextField = "Gasket"; ddlGasket.DataBind(); } catch { ddlGasket.SelectedIndex = 0; } } else { ddlFlange.SelectedIndex = 0; } } } }
protected void ddlFlange_SelectedIndexChanged(object sender, EventArgs e) { try { mForm6 master = (mForm6)this.Master; ScriptManager scriptManager = (ScriptManager)master.FindControl("ScriptManagerMaster6"); if (scriptManager.IsInAsyncPostBack) { // cast DropDownList control which has initiated the call: DropDownList ddlFlange = (DropDownList)sender; foreach (GridViewRow row in grdvJl.Rows) { DropDownList ddlFlange2 = (DropDownList)row.FindControl("ddlFlange"); if (ddlFlange2.UniqueID.Contains(ddlFlange.UniqueID)) { DropDownList ddlGasket = (DropDownList)row.FindControl("ddlGasket"); try { WorkJunctionLiningFlangeGasketList workJunctionLiningFlangeGasketList = new WorkJunctionLiningFlangeGasketList(); workJunctionLiningFlangeGasketList.LoadAndAddItem(ddlFlange.SelectedValue, "", Int32.Parse(hdfCompanyId.Value)); ddlGasket.DataSource = workJunctionLiningFlangeGasketList.Table; ddlGasket.DataValueField = "Gasket"; ddlGasket.DataTextField = "Gasket"; ddlGasket.DataBind(); } catch { ddlGasket.SelectedIndex = 0; } } } Save2(); } } catch { } }