Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to delete a group of rows from a datatable?
Message
From
09/12/2007 08:15:59
 
 
To
09/12/2007 07:46:46
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
01274269
Message ID:
01274275
Views:
12
>>
>>string CRefeicao = "01", CFamiliaPrato = "02";
>>
>>foreach (DataRow LinhaDetalhe in Detalhe.Rows)
>>{
>>   string Crefeicao2 = LinhaDetalhe["CRefeicao"].ToString();
>>   string CFAmiliaPrato2 = LinhaDetalhe["CFamiliaPrato"].ToString();
>>
>>  if (CRefeicao == Crefeicao2 & CFamiliaPrato == CFAmiliaPrato2)
>>  {
>>       LinhaDetalhe.Delete();
>>  }
>>}
>>
>
>off the top of my head:
>
>
>
>
>string CRefeicao = "01", CFamiliaPrato = "02";
>int count = Detalhe.Rows.Count
>for (int i = count; i > 0; i--)
>{
>   string Crefeicao2 = Detalhe.Rows[i]["CRefeicao"].ToString();
>   string CFAmiliaPrato2 = Detalhe.Rows[i]["CFamiliaPrato"].ToString();
>
>  if (CRefeicao == Crefeicao2 & CFamiliaPrato == CFAmiliaPrato2)
>  {
>       Detalhe.Rows[i].Delete();
>  }
>}
>
Thank you John.

It's obvious that my problem would be solved with a loop from the end to the beginning, but i choosed the easiest solution: ask someone.

I'm ashamed.

Thank you,
Joaquim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform