lulu50
asked on
Error cannot convert string[] to string
Hi,
I'm getting an error that says " Cannot convert string[] to string "
My data in the database for the commitID field looks like this:
...but, my dropdown list has the list as a string[]:
My dropdown list is on the search page to filter the data but I'm not getting any data right after the commitID code not able to filter the data:
I tried any() or put the model.SelectedCommitID in a list but it did not work either. These are all my failing trials:
I'm getting an error that says " Cannot convert string[] to string "
My data in the database for the commitID field looks like this:
CommitID
29384484, 35283847, 44757583
48475739
85757573, 95857374
75757573
...but, my dropdown list has the list as a string[]:
29384484
35283847
44757583
48475739
85757573
95857374
75757573
My dropdown list is on the search page to filter the data but I'm not getting any data right after the commitID code not able to filter the data:
if (model.SelectedCommitID != null)
list = list.Where(x => x.CommitID.Contains(model.SelectedCommitID)); //I get an error here that says "cannot convert string[] to string"
I tried any() or put the model.SelectedCommitID in a list but it did not work either. These are all my failing trials:
//Filter Commit ID
// if (model.SelectedCommitID != null)
// {
// List<string> stringlist = new List<string>();
// stringlist.Add(model.SelectedCommitID.ToString());
// list = list.Where(x => x.CommitID.Contains(stringlist.ToString()));
// }
// list = list.Where(x => x.CommitID.Contains(model.SelectedCommitID)); (Did not work)
//list = list.Where(x => x.CommitID.Contains(model.SelectedCommitID.ToString())); (Did not work)
//list = list.Where(x => model.SelectedCommitID.Any(m => Equals(x.CommitID.ToString(), m))); (Did not work)
//list = list.Where(x => x.CommitID.Contains(model.SelectedCommitID.ToString())); (Did not work)
What are the types for each of these:
SelectedCommitID
list
CommitID
-saige-
SelectedCommitID
list
CommitID
-saige-
ASKER
public string[] SelectedCommitID { get; set; }
database table RuleDetail
CommitID varchar(1000)
database table RuleDetail
CommitID varchar(1000)
ASKER
IEnumerable<CABR_RuleDetai l> list = new List<CABR_RuleDetail>();
list = _unitOfWorkCABusinessRules .RuleDetai lRepo.GetA ll().ToLis t();
list = _unitOfWorkCABusinessRules
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wow!!!!
it's working!!!!!
saige Thank you !!!!
Wow wow
Thank you
Thank you
Thank you
one more
Thank you
it's working!!!!!
saige Thank you !!!!
Wow wow
Thank you
Thank you
Thank you
one more
Thank you
ASKER
saige,
wow Great work!!!
Thank you
wow Great work!!!
Thank you
Glad to help
Open in new window