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