ASP.NET - get the width of the GridView after data binding

I'm trying to make something pretty simple. I have a div tag that displays my gridview. I would like to set the div width property to the gridview width property + a few more pixels. I tried to access the GridView.Width.Value property in the DataBound and Page_Prerender events, but it always returns 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 a DataBound event with no luck.

How can I get the width of the GridView after the data has been bound to it?

+4
source share
1 answer

Just give the div some extras. For instance:

 style="padding:5px 5px;" 
0
source

Source: https://habr.com/ru/post/1397086/


All Articles