Dictionary<string, string> StateList = null; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetState(); } } internal Dictionary<string, string> GetState() { try { StateList = new Dictionary<string, string>(); using (cmd = new SqlCommand("sp_MstState", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@StateCode", "")); cmd.Parameters.Add(new SqlParameter("@StateName", "")); cmd.Parameters.Add(new SqlParameter("@Mode", "S")); if (con.State == ConnectionState.Closed) con.Open(); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { StateList.Add(dr["StateCode"].ToString(), dr["StateName"].ToString()); } } } } catch (Exception ex) { } finally { con.Close(); } return StateList; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)