У меня есть gridview
, как показано на рисунке ниже:Как вставить новую строку между другими строками в gridview boundfield?
В этом gridview
я хочу представить новую строку, которая не имеет какой-либо полностью из клетки, где последний «Grand Total» там положить переменная шахта.
Но вопрос в том, как представить новую строку среди других?
Мой код:
Dim Qty As Double = 0
Dim CostCategory As Double = 0
Dim AssemblyDate As String = Nothing
If GridView1.Rows.Count <> 0 Then
For x As Integer = 0 To GridView1.Rows.Count - 1
For y As Integer = 0 To GridView1.Columns.Count - 1
If y = 0 And GridView1.Rows(x).Cells(1).Text = AssemblyDate Then
GridView1.Rows(x).Cells(1).Text = ""
End If
If GridView1.Rows(x).Cells(1).Text <> Nothing Then
AssemblyDate = GridView1.Rows(x).Cells(1).Text
End If
If y = "9" Then
Qty = Convert.ToDouble(GridView1.Rows(x).Cells(9).Text)
End If
If y = "13" Then
CostCategory = Convert.ToDouble(GridView1.Rows(x).Cells(13).Text)
End If
If y = "14" Then
GridView1.Rows(x).Cells(14).Text = Qty * CostCategory
GridView1.Rows(x).Cells(14).HorizontalAlign = HorizontalAlign.Center
End If
If GridView1.Rows(x).Cells(y).Text = "Yes" Then
GridView1.Rows(x).Cells(y).BackColor = System.Drawing.Color.LawnGreen
ElseIf GridView1.Rows(x).Cells(y).Text = "No" Then
GridView1.Rows(x).Cells(y).BackColor = System.Drawing.Color.Red
End If
Next
Next
End if
до этого кода у меня есть запрос, где я заполнить мой GridView:
Dim myQuery As String = SelectQuery & WhereQuery
SqlDataSource1.SelectCommand = myQuery
SqlDataSource1.DataBind()
GridView1.DataSourceID = "SqlDataSource1"
GridView1.DataBind()
Спасибо большое!
Вы можете добавить новую строку в источнике данных и переназначить, что источник данных в GridView. –
В нижнем колонтитуле да, но не между двумя рядами. – Vladut