Link to home
Start Free TrialLog in
Avatar of pootle_flump
pootle_flump

asked on

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.
Avatar of pootle_flump
pootle_flump

ASKER

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.
Hi Mods

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

Cheers
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?

:-)
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial