TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abhilash J A
536
2.4k
596.4k
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.
List
objproductBL =
new
List
();
objproductBL = objProductDAL.GetProductSpecificaton(productid).Select(item =>
new
ProductItemsBL
{
ProductCategoryName = item.ProductCategoryName,
ProductName = item.ProductName,
AttributeName = item.AttributeName,
ProductImage1 = item.ProductImage1,
ValidValues = item.ValidValues,
ProductDescription = item.ProductDescription,
AttributeMaxLength = item.AttributeMaxLength,
AttributeControlType = item.AttributeControlType
}).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.
public
class
Mymodel
{
public
string
[] arryvalidvalue =
new
string
[] { };
}
Then, implement code like this
List
objproductBL =
new
List
();
objproductBL = objProductDAL.GetProductSpecificaton(productid).Select(item =>
new
ProductItemsBL
{
ProductCategoryName = item.ProductCategoryName,
ProductName = item.ProductName,
AttributeName = item.AttributeName,
ProductImage1 = item.ProductImage1,
ValidValues = item.ValidValues,
ProductDescription = item.ProductDescription,
AttributeMaxLength = item.AttributeMaxLength,
AttributeControlType = item.AttributeControlType
}).ToList();
ProductItemsBL objBL =
new
ProductItemsBL();
/*ListValidValues*/
bool
yesno =
false
;
foreach
(var item
in
objproductBL)
{
for
(
int
i = 0; i < item.ValidValues.Length; i++)
{
if
(item.ValidValues.Substring(i, 1) ==
","
) yesno =
true
;
}
if
(yesno ==
true
)
{
objBL.arryvalidvalue = (item.ValidValues.Split(
new
[] {
","
}, StringSplitOptions.RemoveEmptyEntries));
yesno =
false
;
}
}
// objproductBL.AddRange()
return
objproductBL;
But inside 'return
objproductBL
' getting null 'arryvalidvalue' object. How can I get value?
Please help me...
Reply
Answers (
2
)
Get the array element in between a string in c#
pdf file search and highlight