adsense

Thursday, June 27, 2013

Asp.net Gridview Adjust Row Height

When working with the Asp.net Gridview it is a common that we set a fixed height to the rows of the grid. But I came across a situation where height of the Gridview changes even if RowStyle and
AlternatingRowStyle is specified.

The solution seems to be bit tricky but it worked for me. As Boriss Pavlovs have suggested in the following post you will need to set the row height on page prerender event

        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (dgEvent.Rows.Count > 0)
                dgEvent.Height = new Unit(dgEvent.RowStyle.Height.Value * dgEvent.Rows.Count);
        }

http://stackoverflow.com/questions/13762220/how-to-set-fixed-width-and-height-for-grid-row-which-is-dynamically-generating-i

Cheers
Samitha

No comments:

Post a Comment