2

我正在尝试在 asp.net gridview 的上一个/下一个寻呼机的右侧添加一个按钮控件。我曾尝试使用此站点上的示例,但我需要保留上一个/下一个并将按钮放在寻呼机底部行的右侧。

起初我在下一个单元格中显示了一个小(5px)它,然后经过多次其他尝试,现在甚至没有出现。

如何在保持 gridview 生成的下一个/上一个按钮的同时将按钮向右对齐。

谢谢

    Private Sub grdClientServiceType_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdClientServiceType.RowCreated
    Select Case e.Row.RowType
        Case DataControlRowType.Pager

            'Dim space As New LiteralControl(" ")
            'Dim span1 As New Label
            'span1.Text = " "
            'span1.Style("margin-left") = "50px"


            'Dim butt As New Button
            'butt.ID = "buttShowAvail"
            'butt.BackColor = Drawing.Color.Purple
            'butt.ForeColor = Drawing.Color.White
            'butt.Font.Bold = True
            'butt.ToolTip = "Click for a selection of times available."


            'Dim table As Table = TryCast(e.Row.Cells(0).Controls(0), Table)
            'Dim parentCell As TableCell = table.Rows(0).Cells(table.Rows(0).Cells.Count - 1)
            'Dim w As Integer = parentCell.Width.Value

            'parentCell.Controls.Add(space)
            'parentCell.Controls.Add(butt)





            Dim butt As New Button
            butt.ID = "buttShowAvail"
            butt.BackColor = Drawing.Color.Purple
            butt.ForeColor = Drawing.Color.White
            butt.Font.Bold = True
            butt.ToolTip = "Click for a selection of times available."

            AddHandler butt.Click, AddressOf buttShowAvail_Click
            e.Row.Cells(0).ColumnSpan -= 1
            Dim td As New TableCell
            Dim span1 As New Label
            span1.Text = "Show"
            span1.Style("margin-left") = "10px"
            td.Controls.Add(span1)
            td.Controls.Add(butt)
            Dim span2 As New Label
            span2.Text = "rows per page"
            td.Controls.Add(span2)
            e.Row.Cells.Add(td)

    End Select

End Sub
4

1 回答 1

4

我终于弄明白了,感谢这个网站。我只需要改变一些事情来让它工作。
解决方案如下...

    Private Sub grdClientServiceType_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdClientServiceType.RowCreated
    Select Case e.Row.RowType
        Case DataControlRowType.Pager

            Dim butt As New Button
            butt.ID = "buttShowAvail"
            butt.BackColor = Drawing.Color.Purple
            butt.ForeColor = Drawing.Color.White
            butt.Font.Bold = True
            butt.ToolTip = "Click for a selection of times available."
            butt.Width = "220"
            butt.Height = "40"
            butt.Text = "Show Availability"
            butt.Font.Size = "11"

            AddHandler butt.Click, AddressOf buttShowAvail_Click
            e.Row.Cells(0).ColumnSpan -= 1
            Dim td As New TableCell
            td.Controls.Add(butt)
            e.Row.Cells.Add(td)

    End Select

End Sub
于 2012-06-01T03:48:24.333 回答