我有一个要为其设置编号的数据网格。代码行数,但现在我所有的行都填满后,想在运行时通过按Tab键添加新行。
这是我正在执行的代码。
Private Sub FillBlankGrid()
Dim tempdt As New DataTable
Try
Dim SalesManId As Integer = 0
StrQuery = "select * from Purchase_Item where 1=2"
temporaryDataset = Objgen.ExecuteDataset(StrQuery)
tempdt = temporaryDataset.Tables(0)
If Not tempdt Is Nothing And tempdt.Rows.Count > 0 Then
Dim i As Integer
Dim DR As DataRow
For i = tempdt.Rows.Count + 1 To 4
DR = tempdt.NewRow
tempdt.Rows.Add(DR)
Next
GrdItem.DataSource = tempdt
GrdItem.CurrentPageIndex = 0
GrdItem.DataBind()
Else
Dim DtMain As New DataTable
Dim rowcount As Integer = 4
Dim DR As DataRow
For i = 1 To rowcount
DR = tempdt.NewRow
tempdt.Rows.Add(DR)
Next
GrdItem.DataSource = tempdt
GrdItem.DataBind()
FillArticle(rowcount)
FillGodown(rowcount)
End If
Catch ex As Exception
PopupMessage("Exception Caught in 'Datagrid' block-", "error", ex.Message)
Finally
temporaryDataset = Nothing
tempdt = Nothing
End Try
End Sub