Last post May 02, 2012 12:33 PM by basheerkal
Apr 26, 2012 05:56 PM|threeo|LINK
i'd LIKE to be able to alter the width of my footerrow's first cell. i can view and even set the text of the cell. but why are the footerrow cells widths always 0?
no matter what's in them
Apr 26, 2012 07:11 PM|Loganix77|LINK
FooterRows from what I have seen always just seem to inherit their width from the cells above. I was able to assign the footer rows a width value using the onrowcreated event.
Sub SetCellWidth(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Footer Then
e.Row.Cells(0).Width = New Unit(60, UnitType.Pixel)
e.Row.Cells(1).Width = New Unit(60, UnitType.Pixel)
e.Row.Cells(2).Width = New Unit(60, UnitType.Pixel)
e.Row.Cells(3).Width = New Unit(300, UnitType.Pixel)
e.Row.Cells(4).Width = New Unit(60, UnitType.Pixel)
e.Row.Cells(5).Width = New Unit(60, UnitType.Pixel)
e.Row.Cells(6).Width = New Unit(60, UnitType.Pixel)
Apr 26, 2012 07:20 PM|threeo|LINK
my whole problem is this:
i have two grids and after the second grid (which has a footer showing it's totals - as does the first grid) i need to display something which will show grand totals - the sum of the totals between both grids
currently i am just using a table but i ran into an issue as the cells don't expand the same as the cells in the grids
my idea was to detect the width of the cell in the grid and just make the width of the table td the same
but apparently there is NO WAY to get the width of a grid cell
Apr 26, 2012 08:00 PM|Loganix77|LINK
Ahhh...no. I ran into almost this exact same problem when exporting a gridview to an xml file and trying to set the widths of the cells in the xml equal to or trying to use a linear equation to determine the best cell width in the xml doc based on the gridview's
cell width. Everytime I tried to get the value of the width of the cell it was always 0.
This is why I had to use the onrowcreated event to set a cell width for the cells. By doing this I was able to create a variable = cell.width. Otherwise like you're saying my widths were always 0. If you're allowing the cell widths to be dynmaic when
the gridview is created then I have absolutely no idea how you will be able to get the width.
If you're dealing with numbers what you could try and do is use a linear equation based on the length of the value in the cell. So say 0 represents the widest character value in the cell. Now let's assume that 0 represents a width of 2. You could do something
like cell.width = Len(Cell.Text)*2
This may be close enough that the data your presenting would be neat enough for your standards.
If someone is able to tell you how to extract the cell width from a dynamic cell then I'm all ears. I struggled with that exact same problem and in the end just decided to use the onrowcreated to set the cell width values so I could pull them. It just
meant I had to play with width values until I found just the right combination of widths for my cells to present the user with a clean enough xml doc to satisfy me.
May 02, 2012 11:19 AM|superguppie|LINK
Width (and Height) is used only to explicitly specify size. If it is not set, the size is determined by the browser. This size is never known server side.
You may want to consider using ListView instead of GridView. With that you can have the ListViews make trs and tds, and wrap it all in a single table. Then you can make the grand total as just another tr with tds, within the same table.
May 02, 2012 11:24 AM|jamshed alam|LINK
In which event of gridview ur altering it's size? see about gridview event
May 02, 2012 12:33 PM|basheerkal|LINK
In all rows width of cell in a column will be same . How can you individually set the width of a cell in a footer row?. I failed to get what do you mean. Please make it clear for me.