G
Guest
Hi,
I would like to set the column widths in the ASP.NET GridView control at
runtime
I have tried the following:
http://msdn2.microsoft.com/en-us/library/ms178296.aspx
Which uses the following code on a button:
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Try
Dim colWidth As Integer
colWidth = CInt(Server.HtmlEncode(TextBox1.Text))
If colWidth > 0 Then
For i As Integer = 0 To GridView1.Columns.Count - 1
GridView1.Columns(i).ItemStyle.Width = colWidth
Next
End If
Catch
' Report error.
End Try
End Sub
But the count on the columns collection returns 0.
I have tried putting the code immediately before and after the databind but
that doesn't work either.
Could someone please tell me what I am doing wrong?
Regards
Steve
I would like to set the column widths in the ASP.NET GridView control at
runtime
I have tried the following:
http://msdn2.microsoft.com/en-us/library/ms178296.aspx
Which uses the following code on a button:
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Try
Dim colWidth As Integer
colWidth = CInt(Server.HtmlEncode(TextBox1.Text))
If colWidth > 0 Then
For i As Integer = 0 To GridView1.Columns.Count - 1
GridView1.Columns(i).ItemStyle.Width = colWidth
Next
End If
Catch
' Report error.
End Try
End Sub
But the count on the columns collection returns 0.
I have tried putting the code immediately before and after the databind but
that doesn't work either.
Could someone please tell me what I am doing wrong?
Regards
Steve