I'm displaying a gridview2 within a gridview1 row and want to set the column widths of gridview2 to be consistent across all gridview2s.
i.e If row 1 automatically sizes gridview2 colums 1,2,3 to 10,20,30 and row 2 automatically sizes gridview2 columns to 5,25,20 , I want to resize each gridview2 in all rows to 10,25,30
I've tried reading the item style on each gridview column and I get back what I've loaded not what is about to be rendered.
I've used the following code to attempt this with not much success.
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Gv1 As GridViewDim Gv2 As GridView
Dim Gv1r As GridViewRow
Dim R1 As Integer
Dim i As Integer
Dim G2Columns() As Integer
Gv1 = GridView1
Gv2 = Gv1.Rows(0).FindControl("GridView2")
ReDim G2Columns(Gv2.Columns.Count)For R1 = 0 To Gv1.Rows.Count - 1
Gv1r = Gv1.Rows(R1)
Gv2 = Gv1r.FindControl(
"GridView2")For i = 0 To Gv2.Columns.Count - 1
If Gv2.Columns(i).ControlStyle.Width.Value > G2Columns(i) Then
G2Columns(i) = Gv2.Columns(i).ControlStyle.Width.Value
End If
Next
NextFor R1 = 0 To Gv1.Rows.Count - 1
Gv1r = Gv1.Rows(R1)
Gv2 = Gv1r.FindControl(
"GridView2")For i = 0 To Gv2.Columns.Count - 1
Gv2.Columns(i).ItemStyle.Width = G2Columns(i)
Next
Next
End Sub
Is there any way of getting the actual rendered size of each column?
Any help would be appreciated