?
Solved

Alter GridView columns properties

Posted on 2006-05-15
4
Medium Priority
?
231 Views
Last Modified: 2010-07-27
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.
0
Comment
Question by:pootle_flump
  • 3
4 Comments
 
LVL 11

Author Comment

by:pootle_flump
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.
0
 
LVL 11

Author Comment

by:pootle_flump
ID: 16689169
Hi Mods

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

Cheers
0
 
LVL 11

Author Comment

by:pootle_flump
ID: 16689314
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
 

Accepted Solution

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

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