public static String GetDestinations(String sourceId) { try { ClsBAL objBAL = new ClsBAL(); DataSet ObjDataset = objBAL.GetDestinations(sourceId); StringBuilder sbDestinations = new StringBuilder(); if (ObjDataset != null) { if (ObjDataset.Tables.Count > 0) { DataTable dtDestinations = ObjDataset.Tables[0]; HttpContext.Current.Session["sesDTDestinations"] = dtDestinations; sbDestinations.Append("<select id=\"ddldestinationsDiv\" name=\"ddldestinationsDiv\" style=\"width:130px;\" >"); sbDestinations.Append("<option value=''>----------</option>"); if (dtDestinations.Rows.Count > 0) { foreach (DataRow item in dtDestinations.Rows) { sbDestinations.Append("<option value=" + item["ID"].ToString() + ">" + item["DestinationName"].ToString() + "</option>"); } } sbDestinations.Append("</select>"); } } return sbDestinations.ToString(); } catch (Exception ex) { throw ex; } }
protected void ddlSources_SelectedIndexChanged(object sender, EventArgs e) { try { ddlDestinations.Items.Clear(); ddlDestinations.Items.Insert(0, "----------"); if (ddlSources.SelectedIndex != 0 && ddlSources.SelectedItem.Value != "----------") { string str = ddlSources.SelectedItem.Value.ToString(); objBAL = new ClsBAL(); objDataSet = objBAL.GetDestinations(str); if (objDataSet != null) { if (objDataSet.Tables.Count > 0) { if (objDataSet.Tables[0].Rows.Count > 0) { Session["sesDTDestinations"] = objDataSet.Tables[0]; ddlDestinations.Items.Clear(); ddlDestinations.DataSource = objDataSet.Tables[0]; ddlDestinations.DataTextField = "DestinationName"; ddlDestinations.DataValueField = "ID"; ddlDestinations.DataBind(); ddlDestinations.Items.Insert(0, "----------"); } } } } } catch (Exception) { throw; } }