我正在做这样的事情 - 试图在页脚中有一个按钮跨越多个列。
我在通过代码设置 columnspan 时遇到了一个问题,因为 a) 我是菜鸟,b) 它没有 符合我的预期。我不记得所有的细节,但其中有一些陷阱——比如添加额外的列之类的。
这是我的解决方案。也许其中一些会很有用。我在 gridview (gvDocs) 的预渲染中做了。
让我正常工作的原因是以编程方式删除页脚的单元格以及设置列跨度。
即使代码没有帮助,也许人们会因为我的健忘问题而发笑。它有时让我发笑。
Protected Sub gvDocs_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvDocs.PreRender
If gvDocs.Rows.Count > 0 Then
Dim m As Integer = gvDocs.FooterRow.Cells.Count
For i As Integer = m - 1 To 1 Step -1
If i <> 8 Then '7 is the number of the column with the applychanges button in it.
gvDocs.FooterRow.Cells.RemoveAt(i)
End If
Next i
gvDocs.FooterRow.Cells(1).ColumnSpan = 6 '6 is the number of visible columns to span.
End If
End Sub
Fernando68 - 这是在 C# 中
protected void gvDocs_PreRender(object sender, System.EventArgs e)
{
if (gvDocs.Rows.Count > 0) {
int m = gvDocs.FooterRow.Cells.Count;
for (int i = m - 1; i >= 1; i += -1) {
//7 is the number of the column with the applychanges button in it.
if (i != 8) {
gvDocs.FooterRow.Cells.RemoveAt(i);
}
}
gvDocs.FooterRow.Cells[1].ColumnSpan = 6;
//6 is the number of visible columns to span.
}
}
//=======================================================
//Service provided by Telerik (www.telerik.com)
//Conversion powered by NRefactory.
//Twitter: @telerik
//Facebook: facebook.com/telerik
//=======================================================
已编辑 - 需要使用方括号按页脚行中的索引访问单元格