Jagjit Saini

Jagjit Saini

  • NA
  • 166
  • 0

How to display Data in DropDown List

Jun 13 2011 2:25 AM
Hi

public List<nsBo.clsorgprp> disp_rec()
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("disp_org", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();
            List<nsBo.clsorgprp> obj = new List<nsBo.clsorgprp>();
            while (dr.Read())
            {
                nsBo.clsorgprp k = new nsBo.clsorgprp();
                k.p_orgcod = Convert.ToInt32(dr[0]);
                k.p_orgnam = dr[1].ToString();
                k.p_orgdom = dr[2].ToString();
                k.p_orgcrtdat = Convert.ToDateTime(dr[3]);
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return obj;
        }

Now in Presentation layer i want to display name in drop down list and value field = code. How it can be done.


Thanks

Answers (1)