Alter GridView columns properties

Posted on 2006-05-15
Medium Priority
Last Modified: 2010-07-27
VS 2005


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"


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


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?


EDIT - changed title and some text - I had written DataView instead of GridView a couple of times.
Question by:pootle_flump
  • 3
LVL 11

Author Comment

ID: 16680985
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.
LVL 11

Author Comment

ID: 16689169
Hi Mods

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

LVL 11

Author Comment

ID: 16689314

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?


Accepted Solution

GranMod earned 0 total points
ID: 16689507
Closed, 500 points refunded.
The Experts Exchange
Community Support Moderator of all Ages

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question