Add control to right of previous/next of pager in asp.net gridview

╄→尐↘猪︶ㄣ 提交于 2019-12-22 18:22:09

问题


I am trying to add a button control to right of the previous/next of pager in asp.net gridview. I've tried to work with examples on this site, but I need to keep the previous/next and put the button to the right of the bottom pager row.

At first I got a small (5px) it to show in the next cell, then after numerous other attempts, in now doesn't even appear.

How do I align a button to the right while keeping gridview generated next/previous buttons.

Thanks

    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

回答1:


I finally figured it out, thanks to this site. I just need to change a few things to get this to work.
The solution is below...

    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


来源:https://stackoverflow.com/questions/10826235/add-control-to-right-of-previous-next-of-pager-in-asp-net-gridview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!