У меня есть сетка и добавить одну строку, используя RowDataBound. Это появляется дважды. Поэтому я распечатываю e.Row.RowType, он показывает «верхний колонтитул dataRow верхний колонтитул dataRow»
Был уволен дважды по какой-то причине. Почему это событие происходит дважды?
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" EmptyDataText="There is nothing in your shopping cart." GridLines="None" ShowFooter="true" DataKeyNames="id" OnRowDataBound="gv_RowDataBound" EnableModelValidation="True" >
<Columns>
<asp:TemplateField HeaderText="Item" SortExpression="name">
<ItemTemplate>
<asp:Label ID="ItemContentId" runat="server" Text='<%# Eval("publicationContentId").ToString() %>'></asp:Label>
<asp:Label ID="ItemField" runat="server" Text='<%# Eval("name").ToString() %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
BindData()
End If
End Sub
Protected Sub BindData()
gv.DataSource = ShoppingCart.Instance.Items
gv.DataBind()
End Sub
Protected Sub gvPublications_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gvPublications.RowDataBound
Response.Write(e.Row.RowType.ToString() + "<br/>")
' Dim row2 As New GridViewRow(0, 0, DataControlRowType.Footer, DataControlRowState.Normal)
' For i As Integer = 0 To TotalItems
' Dim emptyCell As New TableCell
' row2.Cells.Add(emptyCell)
' Next
' total = 10
' row2.Cells(lastIndex).Text = "<strong>" + DisplayMoney(total.ToString()) + "</strong>"
' gv.Controls(0).Controls.Add(row2)
End Sub