Link to home
Start Free TrialLog in
Avatar of lulu50
lulu50Flag for United States of America

asked on

Filter my data by the commitID

I have a search page that filter the commitID


If the user enter 4534565434 - > I'll get the record
if the user enter 488573377 -> I'm not getting any record

so it only get the first commitID  

my data in the database looks like this:
RuleDetailID                  CommitID
39                                       4534565434, 488573377
40                                        7876545665
41                                        678765456765
42                                       4958574757
43                                      9878787678, 39484723, 494858573
44                                      2343454345
48                                     3434433444
49                                     6756765443
51                                     6444345556, 32423443


                    //Filter CommitID
                    if (model.SelectedCommitID != null)
                    {
                        list = list.Where(x => x.CommitID != null && model.SelectedCommitID.Any(m => Array.IndexOf(x.CommitID.Split(','), m) > -1));
                    }




                    //Filter CommitID
                    if (model.SelectedCommitID != null)
                    {
                       list = list.Where(x => x.CommitID != null && model.SelectedCommitID.Any(m => Array.IndexOf(x.CommitID.Split(','), m) > -1));
                    }

Open in new window

Avatar of lulu50
lulu50
Flag of United States of America image

ASKER

This is how my data in HTML

<select name="CommitIDListID" class="btn btn-default dropdown-toggle" id="CommitIDListID" multiple="multiple">
                                        <option value="2343454345">2343454345</option>
                                        <option value="32423443">32423443</option>
                                        <option value="3434433444">3434433444</option>
                                        <option value="39484723">39484723</option>
                                        <option value="4534565434">4534565434</option>
                                        <option value="488573377">488573377</option>
                                        <option value="494858573">494858573</option>
                                        <option value="4958574757">4958574757</option>
                                        <option value="6444345556">6444345556</option>
                                        <option value="6756765443">6756765443</option>
                                        <option value="678765456765">678765456765</option>
                                        <option value="7876545665">7876545665</option>
                                        <option value="9878787678">9878787678</option>
                                        <option value="d">d</option>
                                        <option value="test">test</option>
                            </select>

Open in new window

Avatar of it_saige
What is the type of SelectedCommitID.

-saige-
Avatar of lulu50

ASKER

   public string[] SelectedCommitID { get; set; }


in the database

CommitID varchar(1000) Checked
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lulu50

ASKER

it_saige,

It works great!!!

list = list.Where(x => model.SelectedCommitID.Any(s => x.CommitID != null && x.CommitID.Split(',').Any(v => Equals(v.Trim(), s.Trim()))));

Thank you so much for everything.

I appreciate all the time you have spent to help me.

you are great and your skills/gift is amazing

the site shine because of you.

Great Heart.

Thank you
Lulu
Glad to help

-saige-