顧名思義,我試圖將數據表中的行分組。爲了進一步詳細說明,該表除了一個字段(列)以外具有相同的行。基本上我試圖做的是把所有不同的領域的相同的行,並把他們在單個領域,同時刪除其他行。在VB中分組數據表的行asp.net 2.0
這裏是我目前正在使用
Dim i As Integer
Dim j As Integer
For i = 0 To (ds.Tables(0).Rows.Count() - 1) Step 1
If (i < ds.Tables(0).Rows.Count()) Then
roleHtml = "<table><tr><td>" + ds.Tables(0).Rows(i).Item("roleName") + "</td></tr>"
For j = (ds.Tables(0).Rows.Count() - 1) To 0 Step -1
If (ds.Tables(0).Rows(i).Item("UserName") = ds.Tables(0).Rows(j).Item("UserName")) And (ds.Tables(0).Rows(i).Item("roleName") IsNot ds.Tables(0).Rows(j).Item("roleName")) Then
roleHtml += "<tr><td>" + ds.Tables(0).Rows(j).Item("roleName") + "</td></tr>"
ds.Tables(0).Rows.Remove(ds.Tables(0).Rows(j))
i -= 1
End If
Next j
roleHtml += "</table>"
ds.Tables(0).Rows(i).Item("roleName") = roleHtml
End If
Next i
問題被刪除時,行其指數的變化,基本上領域獲取有什麼用它做另一行拋出的語法。
乾杯隊友將稍後檢查 – Drahcir 2008-12-12 17:05:12