Exemplo n.º 1
0
 protected void BindCity()
 {
     try
     {
         string state = null;
         if (ddlState.SelectedValue != "-1")
         {
             DataTable Dtaable = TMSCity.GetSearch(null, Convert.ToInt32(ddlState.SelectedValue), null, 1).Tables[0];
             DataView  Dv      = new DataView(Dtaable);
             Dv.Sort                = ("CT_City ASC");
             ddlCity.DataSource     = Dtaable;
             ddlCity.DataTextField  = "CT_City";
             ddlCity.DataValueField = "CT_Id";
             ddlCity.DataBind();
             ddlCity.Items.Insert(0, new ListItem("Select", "0"));
         }
         else
         {
             DataTable Dtaable = TMSCity.GetSearch(null, Convert.ToInt32(state), null, 1).Tables[0];
             DataView  Dv      = new DataView(Dtaable);
             Dv.Sort                = ("CT_City ASC");
             ddlCity.DataSource     = Dtaable;
             ddlCity.DataTextField  = "CT_City";
             ddlCity.DataValueField = "CT_Id";
             ddlCity.DataBind();
             ddlCity.Items.Insert(0, new ListItem("Select", "0"));
         }
     }
     catch (Exception ex) { }
 }
Exemplo n.º 2
0
    public CascadingDropDownNameValue[] BindCity(string knownCategoryValues, string category)
    {
        string[] str     = knownCategoryValues.Split(':');
        int      StateId = Convert.ToInt32(str[2].Substring(0, str[2].IndexOf(';')));

        DataTable dtCity = new DataTable();

        dtCity = TMSCity.GetSearch(null, StateId, null, 1).Tables[0];

        List <CascadingDropDownNameValue> cascadingValues = new List <CascadingDropDownNameValue>();

        for (int i = 0; i < dtCity.Rows.Count; i++)
        {
            string CityId   = dtCity.Rows[i]["CT_Id"].ToString();
            string CityName = dtCity.Rows[i]["CT_City"].ToString();
            cascadingValues.Add(new CascadingDropDownNameValue(CityName, CityId));
        }

        return(cascadingValues.ToArray());
    }