asp.net - 在asp.net gridview中将控件添加到分页器的上一个/下一个右侧

标签 asp.net gridview

我正在尝试在 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

最佳答案

感谢这个网站,我终于明白了。我只需要更改一些内容即可使其正常工作。
解决方案如下...

    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

关于asp.net - 在asp.net gridview中将控件添加到分页器的上一个/下一个右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10826235/

相关文章:

android - 从适配器中的 Assets 文件夹添加 SVG 图像

c# - Lucene 支持 Unicode 吗?

asp.net - Linq 查询返回同一行 12 次

c# - 事件处理程序中的属性值不正确

jquery - 从网站 Jquery Grid 中提取数据

c# - 如何将字典绑定(bind)到 gridview?

asp.net - 使用具有基本身份验证的 Web 服务

asp.net - 具有调整大小的ASP.NET图像上传

c# - 特殊(或外国)字符

android - GridView 中 ArrayAdapter 的自定义过滤器