Alter GridView columns properties

VS 2005
ASP.Net
VB.NET

Hi

New to ASP.NET (and especially VS 2005). I'm struggling with the formatting of a GridView control's columns.

In General Decs:
      Dim AttAdapter As SqlDataAdapter
      Dim AttSet As dataset
          Dim Connection As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("AttConString"))
          Dim AttCommand As SqlCommand

In New():

      AttCommand = New SqlCommand("dbo.MySproc", Connection)
        AttCommand.CommandType = Data.CommandType.StoredProcedure

        AttAdapter = New SqlDataAdapter(AttCommand)
        AttSet = New DataSet
        AttAdapter.Fill(AttSet, "AttDets")

In load():

        Me.MyGridView.DataSource = AttSet
        Me.MyGridView.DataMember = "AttDets"

        Me.MyGridView.DataBind()


The GridView control is populated correctly however I cannot set the GridView column widths. If I try:

Debug.Print(Me.MyGridView.Columns.Count)

in a button click handler it returns 0.

The columns are known at design time so I can specify this then if required. Please could someone let me know what I am missing?

Thanks

EDIT - changed title and some text - I had written DataView instead of GridView a couple of times.
LVL 11
pootle_flumpAsked:
Who is Participating?
 
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0
 
pootle_flumpAuthor Commented:
Duh - forgot to mention that for unimportant reasons I can't use the GridView headers - I am having to create my own. As such, I hide the headers but would like to format the column widths rather than have them autofit to the data.
0
 
pootle_flumpAuthor Commented:
Hi Mods

I think I have cracked this. I will post the solution shortly.

Cheers
0
 
pootle_flumpAuthor Commented:
Solution:
http://www.dbforums.com/showthread.php?p=4545223&posted=1#post4545223

Mods - apols for the link. If you would rather I pasted the solution on here please let me know.

Please may I also have my points refunded?

:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.