2013年6月26日 星期三

GridView 加入控制項至Pager Row ( Adding Controls To Pager Row )

在 GridView 加入 OnRowDataBound 事件:
<asp:gridview id="gv1" runat="server" autogeneratecolumns="False" onrowdatabound="gv1_RowDataBound" allowpaging="True">

in code-behind:
Protected Sub gv1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.Pager Then
        Dim myLabel As Label = New Label
        Dim table As Table = e.Row.Cells(0).Controls(0)
        Dim parentCell As TableCell = table.Rows(0).Cells(table.Rows(0).Cells.Count - 1)
        parentCell.Controls.Add(myLabel)
        myLabel.Text = "Some Text"
    End If
End Sub

沒有留言:

張貼留言