I’m trying to do something fairly simple. I’ve got a div tag in which my gridview is displayed. I’d like to set the div width property to the gridview’s width property + a few more pixels. I’ve tried to access the GridView.Width.Value property in the DataBound and Page_Prerender events but it’s always returning 0:
protected void Page_Prerender(object sender, EventArgs e)
{
string sWidth = gvUsers.Width.Value.ToString();
divContactForm.Attributes.Add("style", "width: " + sWidth + " ;");
}
I tried the same code in the DataBound event with no luck.
How can I get the GridView’s width after the data has been bound to it?
Just give the div some padding. For example: