Jagjit Saini

Jagjit Saini

  • NA
  • 166
  • 0

Unable to Display in Gridview using List Collection

Jun 8 2011 1:00 PM

namespace nsBo
{
    public interface intorg
    {
        Int32 p_orgcod
        {
            get;
            set;
        }
        string p_orgnam
        {
            get;
            set;
        }
    }

    public class clsorgprp : intorg
    {
        private Int32 prvorgcod;
        private string  prvorgnam, prvorgdom;
        private DateTime prvorgcrtdat;

        public int p_orgcod
        {
            get
            {
                return prvorgcod;
            }
            set
            {
                prvorgcod = value;
            }
        }
        public string p_orgnam
        {
            get
            {
                return prvorgnam;
            }
            set
            {
                prvorgnam = value;
            }
        }
       
    }
}

namespace nsDal

{

}


namespace nsBll{
public List<nsBo.clsorgprp> disp_rec()
        {
            nsDal.clsorg pDal = new nsDal.clsorg();
            try
            {
                return pDal.disp_rec();
            }
            catch
            {
                throw;
            }
            finally
            {
                pDal = null;
            }
        }
    }


What should i write in UI to display 2 fields in gridview using Template


Thanks

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();
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return obj;
        }

Answers (5)