Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CheckedListBox - Checking Multiple Items
Message
De
19/02/2010 10:09:52
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01449851
Message ID:
01449904
Vues:
29
>That would cause it to continue to loop thru the inner loop after the item is found.

Ah, I see. couple questions. I assume you verified there were more rows than 1 in your collection? Also why this statement
string FilterCaption = dsContactFilters.Tables[0].Rows[0]["Caption"].ToString();
inside the foreach keeps setting the value to the exact same row; first row?

Tim

>
>
>
>>Take the "break;" out.
>>Tim
>>
>>>I have a CheckedListBox with 75 items in it. I then get a DS of 5 items. For each of the 5 items, I want to check the item in the CheckListBox. I'm searching for items by their caption.
>>>
>>>Only the first one is being checked.
>>>
>>>
>>>private void _LoadContactFilters()
>>>{
>>>    SqlParameter pContactId = new SqlParameter("@ContactId", _Contact.RecordId);
>>>    List<DbParameter> Params = new List<DbParameter>();
>>>    Params.Add(pContactId);
>>>
>>>    DataSet dsContactFilters = csMain.DataProcs.ExecuteQuery("lb_GetFiltersForContact", Params, CommandType.StoredProcedure);
>>>    if (dsContactFilters.Tables[0].Rows.Count > 0)
>>>    {
>>>        foreach (DataRow Row in dsContactFilters.Tables[0].Rows)
>>>        {
>>>            string FilterCaption = dsContactFilters.Tables[0].Rows[0]["Caption"].ToString();
>>>
>>>            for (int i = 0; i < chklFilters.Items.Count; i++)
>>>            {
>>>                if (chklFilters.Items[i].ToString() == FilterCaption)
>>>                {
>>>                    chklFilters.SetItemChecked(i, true);
>>>                    break;
>>>                }
>>>            }
>>>        }
>>>    }
>>>}
>>>
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform