Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CheckedListBox - Checking Multiple Items
Message
De
19/02/2010 10:25:47
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
19/02/2010 10:18:53
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01449851
Message ID:
01449906
Vues:
19
>Doh - I should have spotted that.
>I think you're first question is probably redundant :-}
>
Redundant? Probably, but I have learned to not discount some things. Wasn't sure if he was seeing the same data posted over and over or if it was not actually looping through more than once. Looks like it should have looped through for each row but got the same results each time.

You saw what happened when I responded before looking close enough :-)
Tim


>>>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
Répondre
Fil
Voir

Click here to load this message in the networking platform