开发者

How to change row height on last page of Gridview

On the last page if If i have 1 or 2 items the header and the pager stretch too much.. it all autosizes..

My gridview height is not set, But I set the row property to 30pixels..still doesnt prevent the autosizing..

I was searching for a solution over the net.开发者_运维知识库.and the closest solution that i found was that:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(this.GridView1.Rows.Count<this.GridView1.PageSize)//I need here to grab the last page..// do something like e.Row.... and last page.
    {
        foreach (GridViewRow tt in GridView1.Rows)
            { tt.Height = Unit.Pixel(30); }
    }
}

It isnt correct.... what i need to happen, is when the user clicks the last page the height should be modified to to 30 pixels.

Any other ideas on how to prevent autosizing on the last page are welcome!!


To find out if you're on the last page of a paged grid and then change row heights, use the following (tested) code:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (GridView1.PageIndex == GridView1.PageCount - 1)
        {
            e.Row.Height = Unit.Pixel(30); 
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜