任何人都可以帮我在c#.Net中创建自定义GridView控件吗?
答案 0 :(得分:1)
这是一篇博客文章和一个代码示例(来自我的一个项目),可以为您提供所需的信息。
ASP.NET 2.0 - Extending GridView control to display extra Footer Rows
public class MyGridView : GridView
{
protected GridViewRow _footerRow = null;
public override GridViewRow FooterRow
{
get
{
if (_footerRow == null)
{
return base.FooterRow;
}
else
{
return _footerRow;
}
}
}
public MyGridView()
{
}
protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding)
{
...
...
}
[System.ComponentModel.Category("Behavior")]
[Themeable(true)]
[System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.No)]
public bool ShowHeaderWhenEmpty
{
get
{
if (this.ViewState["ShowHeaderWhenEmpty"] == null)
{
this.ViewState["ShowHeaderWhenEmpty"] = false;
}
return (bool)this.ViewState["ShowHeaderWhenEmpty"];
}
set
{
this.ViewState["ShowHeaderWhenEmpty"] = value;
}
}
[System.ComponentModel.Category("Behavior")]
[Themeable(true)]
[System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.No)]
public bool ShowFooterWhenEmpty
{
get
{
if (this.ViewState["ShowFooterWhenEmpty"] == null)
{
this.ViewState["ShowFooterWhenEmpty"] = false;
}
return (bool)this.ViewState["ShowFooterWhenEmpty"];
}
set
{
this.ViewState["ShowFooterWhenEmpty"] = value;
}
}
}
答案 1 :(得分:0)
我们需要了解您希望GridView支持的内容,这在标准版中是不可能的。