I have a view model class Paymentcart and inside that I have created object of another two classes payment and cart.
Class Paymentcart
namespace Temple.Models
{
    public class paymentcart
    {
        public cart cart { get; set; }
        public payment payment { get; set; }
    }
}
Class cart:
public class cart
{
         public long cid { get; set; }
         public long vid { get; set; }
         public long userid { get; set; }
         public long count { get; set; }
         public long tempid { get; set; }
         public string  name { get; set; }
         public string star { get; set; }
         public string dates { get; set; }
         public string vname { get; set; }
         public string vrate { get; set; }
         public string totalamount { get; set; }
         public int rows { get; set; }
}
Class payment:
public class payment
{
        public long cid { get; set; }
        public long vid { get; set; }
        public long userid { get; set; }
        public long tempid { get; set; }
        public string amt { get; set; }
        public string cname { get; set; }
        public long number { get; set; }
        public long securitycode { get; set; }
        public string expdate { get; set; }
        public string totalamount { get; set; }
}
But when I am putting value from the database, it shows "Null Exception" error (but the database does return values).
This is the controller code:
 List<paymentcart> qlist = new List<paymentcart>();
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand("getcart", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                      var q = new paymentcart();
                    q.cart = new cart();
                    cmd.Parameters.AddWithValue("@uid", uid);
                    con.Open();
                    SqlDataReader rd = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                         q.cart.tempid = Convert.ToInt64(rd["TdId"]);
                          q.cart.userid  = Convert.ToInt32(rd["UserID"]);
                           q.cart.cid = Convert.ToInt32(rd["cid"]);
                           q.cart. vid = Convert.ToInt32(rd["v_id"]);
                            q.cart.name = Convert.ToString(rd["name"]);
                           q.cart. star = Convert.ToString(rd["star"]);
                           q.cart. dates = Convert.ToString(rd["dates"]);
                            q.cart.vname = Convert.ToString(rd["vname"]);
                           q.cart. vrate = Convert.ToString(rd["vrate"]);
                           qlist.Add(q);
                    }
                }
            }
            return qlist;
I have attached a screenshot here: Error Page
I don't know am using the correct method; please help me to solve this.
 
     
    