[原创]动态增加和删除DataGrid中的行
'*type为1表示要增加行 2为减去行
Private Sub rowChange(ByVal type As Integer,byval GridType as DataGrid)
Select Case type
Case 1
GridType.DataSource = CreateDataSource(Me.GridType.Items.Count + 1)
GridType.DataBind()
Case 2
GridType.DataSource = CreateDataSource(Me.GridType.Items.Count - 1)
GridType.DataBind()
End Select
End Sub
Function CreateDataSource(ByVal h As Integer) As ICollection
Dim dt As New DataTable
Dim dr As DataRow
Dim i As Integer
For i = 0 To h - 1
dr = dt.NewRow()
dt.Rows.Add(dr)
Next i
Dim dv As New DataView(dt)
Return dv
End Function