setting the columns width of a gridview
-
hi i have a gridview manually bounded to an accsess db. how can i adjust (in my case reduce) the width of specific columns? i've tried to set the width for the header,footer and item templates but all it did was narrowing an invisible text area - caused the text to wrap down but the size of the column remained the same... help on this will be very appreciated.. thanks j
-
hi i have a gridview manually bounded to an accsess db. how can i adjust (in my case reduce) the width of specific columns? i've tried to set the width for the header,footer and item templates but all it did was narrowing an invisible text area - caused the text to wrap down but the size of the column remained the same... help on this will be very appreciated.. thanks j
try, eg: ....Columns(1).ItemStyle.Width = System.Web.UI.WebControls.Unit.Percentage(30) or ....Columns(1).ItemStyle.Width = System.Web.UI.WebControls.Unit.Pixel(100)
-
try, eg: ....Columns(1).ItemStyle.Width = System.Web.UI.WebControls.Unit.Percentage(30) or ....Columns(1).ItemStyle.Width = System.Web.UI.WebControls.Unit.Pixel(100)
-
hmm, well... remember that web-controls are rendered on the page as straight HTML - tables in this case. Take a look at the page source of one of your pages and see the HTML code there - is there an appropriate in there? Assuming so, remember that the width may still display incorrectly if the other column widths are either not set or are contradictory...
-
hmm, well... remember that web-controls are rendered on the page as straight HTML - tables in this case. Take a look at the page source of one of your pages and see the HTML code there - is there an appropriate in there? Assuming so, remember that the width may still display incorrectly if the other column widths are either not set or are contradictory...
-
i've looked at the source code and width is appearing as i've set it, i.e. if i'm using: gridView.Columns[4].ItemStyle.Width = Unit.Percentage(30); i'm getting: td style="width:30%;" how do you think setting the width issue can be solved? thanks, J
Then something else is throwing it off - you will have to examine the HTML to see what it might be: - something with a non-variable width (eg an image) that is wider than the column width allocated - are column widths set for ALL columns? - if so, are they contradictory (maybe they add up to only 90%, or 110%) - is an overall table width set? if so, does it tally with the sum of the column widths? - have you taken table borders, cellspacing and cellpadding into account, as well as margins/borders round objects within (eg images, again) - is this a browser-specific issue? All sorts of things can combine to throw off a table display - but at least you know the correct width is being applied via your code. All you need to do is figure out what's wrong in the resultant HTML and adjust things accordingly....
-
Then something else is throwing it off - you will have to examine the HTML to see what it might be: - something with a non-variable width (eg an image) that is wider than the column width allocated - are column widths set for ALL columns? - if so, are they contradictory (maybe they add up to only 90%, or 110%) - is an overall table width set? if so, does it tally with the sum of the column widths? - have you taken table borders, cellspacing and cellpadding into account, as well as margins/borders round objects within (eg images, again) - is this a browser-specific issue? All sorts of things can combine to throw off a table display - but at least you know the correct width is being applied via your code. All you need to do is figure out what's wrong in the resultant HTML and adjust things accordingly....