开发者

How to change row height on last page of Gridview

开发者 https://www.devze.com 2023-03-17 23:48 出处:网络
On the last page if If i have 1 or 2 items the header and the pager stretch too much.. it all autosizes..

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

精彩评论

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

关注公众号