0%

GridView 加入空白行

  • Function如下 ```vb
    ‘’’
    ‘’’’’’

    ‘’’ 要新增空白行的GridView
    ‘’’ 要加入幾行
    ‘’’
    Public Shared Sub GridView_AddEmptyRow(gv As GridView, count As Integer)
    Dim dt As DataTable = New DataTable()
    Dim dr As DataRow
    For i = 0 To gv.Columns.Count - 1 Step 1
      dt.Columns.Add(New DataColumn(gv.Columns(i).HeaderText, System.Type.GetType("System.String")))
    
    Next
    For i = 1 To count Step 1
      dr = dt.NewRow()
      For x = 0 To gv.Columns.Count - 1 Step 1
          dr(gv.Columns(x).HeaderText) = String.Empty
      Next
      dt.Rows.Add(dr)
    
    Next
    gv.DataSource = dt
    gv.DataBind()
    End Sub