protected void ImageButtonUp_Click(object sender, ImageClickEventArgs e) { LabelErrorMessage.Text = ""; dv = (DataView)SqlDataSourceDivision.Select(DataSourceSelectArguments.Empty); if (Ddlist.SelectedValue == "-1") { dv.RowFilter = "CompanyIDParent='0'"; } else { dv.RowFilter = "CompanyID='" + Session["Pre"].ToString() + "'"; } Ddlist.DataSource = dv; if (dv.Count > 0) { Session["Pre"] = dv[0].Row[2].ToString(); Ddlist.DataValueField = "CompanyID"; Ddlist.DataTextField = "CMPCompanyName"; Ddlist.DataBind(); Ddlist.Items.Insert(0, new ListItem("Select One", "-1")); } else { LabelErrorMessage.Text = "This is the last level"; } Session["CompanyIdName"] = Ddlist.SelectedValue; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LabelErrorMessage.Text = ""; dv = (DataView)SqlDataSourceCompany.Select(DataSourceSelectArguments.Empty); Ddlist.DataSource = dv; if (dv.Count > 0) { Ddlist.DataValueField = "CompanyID"; Ddlist.DataTextField = "CMPCompanyName"; Ddlist.DataBind(); Ddlist.Items.Insert(0, new ListItem("Select One", "-1")); } else { LabelErrorMessage.Text = "This is the last level"; } } }