Prasad Bhagat

Prasad Bhagat

  • NA
  • 516
  • 234.7k

how to access inside list values in c#..?

Sep 24 2015 11:27 AM
Dear all ,
 
How to Access values when it is inside in list ..please have a look on code  ..
 
 
public Entity.ProductDetails GetAdminProductDetails(string Id, string CompanyCode)
{
AppLogger.Info("Products : GetProductDetails:: Started");
Entity.ProductDetails productDetails = new Entity.ProductDetails();
productDetails.ResultStatus.StatusInd = -1;
productDetails.ResultStatus.StatusMsg = "";
string appPath = "";
string mapPath = "";
string filePath = "";
DAO.Product getProductDetails = null;
DataSet dsProductDetails = null;
try
{
getProductDetails = new DAO.Product();
dsProductDetails = getProductDetails.GetAdminProductDetails(Id, CompanyCode);
if ((dsProductDetails != null) && (dsProductDetails.Tables.Count > 0))
{
if (dsProductDetails.Tables[0] != null)
{
DataTable dtblProductDetails = dsProductDetails.Tables[0];
AppLogger.Info("Products : GetProductDetails:: Status[" + dtblProductDetails.Rows[0]["STATUSIND"].ToString() + "]");
if (Common.ConvertInt(dtblProductDetails.Rows[0]["STATUSIND"]) == -1)
{
productDetails.ResultStatus.StatusMsg = dtblProductDetails.Rows[0]["STATUSMSG"].ToString();
}
else
{
productDetails.Id = dtblProductDetails.Rows[0]["Id"].ToString();
productDetails.Name = dtblProductDetails.Rows[0]["Name"].ToString();
productDetails.Description = dtblProductDetails.Rows[0]["Description"].ToString(); // Long Description (Wine Master * Wine Details)
productDetails.Vintage = Common.ChangeVintageTo4Digit(dtblProductDetails.Rows[0]["Vintage"].ToString().Trim());
 
 
if (dsProductDetails.Tables[1] != null)
{
DataTable dtblWineRatings = dsProductDetails.Tables[1];
List<Entity.RatingDetails> lstRating = new List<Entity.RatingDetails>();
for (int i = 0; i < dtblWineRatings.Rows.Count; i++)
{
Entity.RatingDetails rating = new Entity.RatingDetails();
rating.Rating = dtblWineRatings.Rows[i]["Rating"].ToString();
rating.Description = dtblWineRatings.Rows[i]["Description"].ToString();
// Commented by Gopi dated on Jun-15-2015
// Reason for : Rating value required 92+ or 92-94. So chnage the data type int to string.
//rating.Value = Common.ConvertInt(dtblWineRatings.Rows[i]["Value"]);
rating.Value = dtblWineRatings.Rows[i]["Value"].ToString();
if (dtblWineRatings.Rows[i]["Description"].ToString() != "" && dtblWineRatings.Rows[i]["Value"].ToString() != "")
rating.PointsDescription = rating.Description + ": " + rating.Value + " points";
rating.TastingNotes = dtblWineRatings.Rows[i]["TastingNotes"].ToString();
rating.CreatedDate = dtblWineRatings.Rows[i]["Date"].ToString();
lstRating.Add(rating);
}
productDetails.LstRatingDetails = lstRating;
}
 
 
 
Come To My UI CODE ....
 
 
WineLegend.BO.Admin.Products obj = new WineLegend.BO.Admin.Products();
try
{
string CompanyCode = "WL";
string ItemNumber = Text9.Text.Trim();
if (ItemNumber.Length > 0)
{
var temp = obj.GetProductDetailsByItemNumber(ItemNumber, CompanyCode);
if (temp != null)
{
if (temp.Name.Length > 0)
Text5.Text = temp.Name;
if (temp.RegularPrice.Length > 0)
Text6.Text = temp.RegularPrice;
if (temp.SalePrice.Length > 0)
Text7.Text = temp.SalePrice;
if (temp.FreeShipping == "Y")
Text4.Text = "+ FREE SHIPPING";
else
Text4.Text = "NO FREE SHIPPING";
if (temp.NoOfBtlFreeShipping > 0)
Text8.Text = "Free Shipping With" + " " + Convert.ToInt32(temp.NoOfBtlFreeShipping).ToString() + " " + "OR More BTLS";
else
Text8.Text = "NO FREE SHIPPING";
if (temp.ImageMedium.Length > 0)
lblImagepath.Text = temp.ImageSmall;
}
}
}
 
 
 
 i want to Acces Above List VALUES ..
 
 
 
 
 
 
 
 

Answers (3)