Gridview 行自动调整大小的问题
基本上我的行根据它所拥有的项目数量自动调整大小。如果它有一项,那么标题、寻呼机都是大尺寸的。
我怎样才能使页眉和页脚固定,并且可能插入一些空行而不是扩展项目..
我尝试通过页面更改事件这样做..但不是很成功,所以我需要帮助..
这是到目前为止我的想法:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if (this.GridView1.Rows.Count < this.GridView1.PageSize)
{
foreach (GridViewRow tt in GridView1.Rows)
{ tt.Height = Unit.Pixel(30); }
}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (this.GridView1.Rows.Count < this.GridView1.PageSize)
{
foreach (GridViewRow tt in GridView1.Rows)
{ tt.Height = Unit.Pixel(30); }
}
}
Basically my rows autosize depending on the number of items it has. If it has one item then,,the header, pager, are all in a big size.
How could I make the header and footer fixed,, and may be insert a few empty rows not to extend the item..
I tried to do so with the page change event..but not very successfully so i need help..
This is what i thought of so far:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if (this.GridView1.Rows.Count < this.GridView1.PageSize)
{
foreach (GridViewRow tt in GridView1.Rows)
{ tt.Height = Unit.Pixel(30); }
}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (this.GridView1.Rows.Count < this.GridView1.PageSize)
{
foreach (GridViewRow tt in GridView1.Rows)
{ tt.Height = Unit.Pixel(30); }
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为您的 Gridview 提供
CSS
,主要是为您的(即 CSS)GridviewsHeaderstyle 和 Rowstyle
属性。Give
CSS
for your Gridview, and mainly for your (ie CSS) GridviewsHeaderstyle and Rowstyle
Properties.你可以尝试使用样式表吗?假设只有一条记录应用一种 CSS 样式或其他普通样式。我认为这是可能的。
如果您需要更多帮助,请告诉我。
Can you try with stylesheet. Let say if only one record apply one CSS Style other vise normal style. I think that is possible.
Let me know if you need more help on this.