public Product ProductById(int id) { Product obj = new Product(); obj.ProductId = id; DataTable dt = new DataTable(); dt = objblproduct.GetProductByID(obj); Product retobj = new Product(); if (dt != null) { if (dt.Rows.Count > 0) { retobj.ProductId = Convert.ToInt32(dt.Rows[0]["ProductId"].ToString()); retobj.ProductName = dt.Rows[0]["ProductName"].ToString(); retobj.ProductImage = dt.Rows[0]["ProductImage"].ToString(); retobj.ActualImage = dt.Rows[0]["ActualImage"].ToString(); retobj.Description = dt.Rows[0]["Description"].ToString(); retobj.InsertedBy = dt.Rows[0]["InsertedBy"].ToString(); retobj.InsertedOn = Convert.ToDateTime(dt.Rows[0]["InsertedOn"].ToString()); retobj.CategaryId = dt.Rows[0]["CategaryId"].ToString(); retobj.SubCategaryId = dt.Rows[0]["SubCategaryId"].ToString(); retobj.CategaryName = dt.Rows[0]["CategaryName"].ToString(); retobj.SubCategaryName = dt.Rows[0]["SubCategaryName"].ToString(); retobj.UpdatedBy = dt.Rows[0]["UpdatedBy"].ToString(); retobj.UpdatedOn = Convert.ToDateTime(dt.Rows[0]["UpdatedOn"].ToString()); } } return(retobj); }