在c#中迭代datarow

时间:2017-01-10 17:06:05

标签: c# datatable datarow

在选定的dataRow中,我有200个数据记录行。现在我需要将200条记录分成20个[10次(循环)]。所以我使用了take(20)。它将获得前20个记录。

我需要删除前20条记录,需要再选择20条记录。我需要执行10次for循环并获取所有200条记录。

DataRow[] selectedDataRow = dtSMSDetails.Select("description = '" + smsDescription + "'");

if (selectedDataRow.Length > 0)
{
    string smsRecordId = "";
    string mobileNum = "";
    string smsSubject = "";

    foreach (DataRow rows in selectedDataRow.Take(20)) 
    {
        smsRecordId += rows["activityid"].ToString() + ",";
        smsSubject = rows["subject"].ToString();
        mobileNum += rows["telephone1"].ToString() + ",";
        // Here I need to remove the first 20 (take 20) records from the selected data row and need to loop next 20 records. 
    }
}

1 个答案:

答案 0 :(得分:3)

您可以使用Visible = Excel.XlSheetVisibility.xlSheetVisible

Skip()

Read more