Abhilash J A

Abhilash J A

  • 501
  • 2.4k
  • 598.1k

How to get string array value to existing list c# ?

Jan 19 2017 1:32 AM
Hello Everyone,
 
I have list items inside objproductBL object.
  1. List objproductBL = new List();  
  2.             objproductBL = objProductDAL.GetProductSpecificaton(productid).Select(item => new ProductItemsBL  
  3.            {  
  4.                ProductCategoryName = item.ProductCategoryName,  
  5.                ProductName = item.ProductName,  
  6.                AttributeName = item.AttributeName,  
  7.                ProductImage1 = item.ProductImage1,  
  8.                ValidValues = item.ValidValues,  
  9.                ProductDescription = item.ProductDescription,  
  10.                AttributeMaxLength = item.AttributeMaxLength,  
  11.                AttributeControlType = item.AttributeControlType  
  12.             }).ToList(); 
 
 
From the list, if the 'AttributeControlType' contain "DropDownList" then I want to show it's 'ValidValues' inside drowpdownlist.
 
 
 
 
 For this, I have tried created a string[] inside model class.
  1. public class Mymodel  
  2.     {  
  3.  public string[] arryvalidvalue = new string[] { };  

 Then, implement code like this
 
  1. List objproductBL = new List();  
  2.             objproductBL = objProductDAL.GetProductSpecificaton(productid).Select(item => new ProductItemsBL  
  3.            {  
  4.                ProductCategoryName = item.ProductCategoryName,  
  5.                ProductName = item.ProductName,  
  6.                AttributeName = item.AttributeName,  
  7.                ProductImage1 = item.ProductImage1,  
  8.                ValidValues = item.ValidValues,  
  9.                ProductDescription = item.ProductDescription,  
  10.                AttributeMaxLength = item.AttributeMaxLength,  
  11.                AttributeControlType = item.AttributeControlType  
  12.             }).ToList();  
  13.   
  14.            ProductItemsBL objBL = new ProductItemsBL();  
  15.            /*ListValidValues*/  
  16.            bool yesno = false;  
  17.            foreach (var item in objproductBL)  
  18.            {  
  19.                for (int i = 0; i < item.ValidValues.Length; i++)  
  20.                {  
  21.                    if (item.ValidValues.Substring(i, 1) == ",") yesno = true;  
  22.                }  
  23.                if (yesno == true)  
  24.                {  
  25.                    objBL.arryvalidvalue = (item.ValidValues.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries));  
  26.                    yesno = false;  
  27.                }  
  28.            }             
  29.   
  30.           // objproductBL.AddRange()  
  31.            return objproductBL; 
 But inside 'return objproductBL' getting null 'arryvalidvalue' object. How can I get value?
 
Please help me...
 

Answers (2)