Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 4th, 2006, 09:34 PM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hiding datagrid column give error

Hi,
I am reposting this under a new topic.

i am facing another new challenge. i am using .net VS2003 with v1.1 framework
instead of using dataset, i used the dataview as the datasource.
gdataGrid.DataSource = ds.Tables(0).defaultview

so that i can do sorting easily. Now i wish to hide one of the column in the datagrid. the data grid has edit and delete column followed by the dataview's column which consist of No, Item, Desc, etc.
I wish to hide the 'No' column. when i specifiy,
gdataGrid.DataSource = ds.Tables(0).defaultview
gdataGrid.DataBind()
gdataGrid.Columns("No").Visible = False

the above statement gives error and when i checked, the gdataGrid.columns().count gives only 2 (the Edit and the Delete columns). somehow, the columns in the dataviews are not being recognised. how to make the datagrid recognize the columns from the dataview?

I tried using the datagridtablestyle, but the datagridtablestyle is also not recognised by the editor.


Thanks.
  #2 (permalink)  
Old April 6th, 2006, 12:07 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

what is the error? and what line does it occur on?
  #3 (permalink)  
Old April 6th, 2006, 02:53 AM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I am able to hide the column now. previously the columns in datagrid is set as template column. i changed it to bound column and gave the field name for each column. :) so now able to hide the column.
Thanks.


  #4 (permalink)  
Old April 6th, 2006, 09:12 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

ok great

  #5 (permalink)  
Old April 6th, 2006, 11:57 PM
Authorized User
 
Join Date: Jan 2006
Location: Pittsburgh, PA 15203
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hai ansary can u send the line u have used to get the a cloumn in the datadrid with bound column if possible dsend me the code snippet of every change we should make to make a particular column false dynamically

thanks
Madhu

  #6 (permalink)  
Old April 7th, 2006, 03:45 AM
Authorized User
 
Join Date: Mar 2006
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Madhu,
i set the column bound in the property builder of the datagrid. not in the code. i created 6 columns including the column i wish to hide and indicated in the property builder, the data field. i left the data field empty when i created the datagrid assuming the datafield is only for records from the database. since i am using the databind to bind the datatable i created dynamically, later i entered the datafield in the property field and then i am able to hide the column i dynamically.

Private Sub CreateDataSet()

        sSessionTag = "Tag" & Session.SessionID
        sSessionSort = "Sort" & Session.SessionID

        dt = New DataTable(sTblName)
        ds = New DataSet
        Dim col0 As DataColumn = New DataColumn("No", System.Type.GetType("System.Int32"))
        Dim col1 As DataColumn = New DataColumn("Name", System.Type.GetType("System.String"))
        ... created rest of columns


        dt.Columns.Add(col0)
        dt.Columns.Add(col1)
        dt.Columns.Add(col2)
        dt.Columns.Add(col3)
        dt.Columns.Add(col4)
        dt.Columns.Add(col5)

        ds.Tables.Add(dt)
    End Sub

Private Sub BindGrid()
        Dim dtgCol As DataGridColumn
        If Session(sSessionSort) Is Nothing Then
            Session(sSessionSort) = "Name"
            Session(sSessionSortOrder) = " Asc"
        Else
            dsTag.Tables(sTblName).DefaultView.Sort = CType(Session(sSessionSort), String) & CType(Session(sSessionSortOrder), String)
        End If
        dsTag.Tables(sTblName).DefaultView.RowFilter = ""
        gdataGrid.DataSource = dsTag.Tables(sTblName).DefaultView
        gdataGrid.DataBind()
        gdataGrid.Visible = True
        If gdataGrid.Columns().Count > 0 Then
            gdataGrid.Columns(0).Visible = False
        End If
    End Sub

regards,
annsary

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hiding / unhiding columns in datagrid drachx General .NET 9 October 18th, 2004 02:37 AM
Hiding datagrid row selection column Ron Howerton VB.NET 2002/2003 Basics 0 September 25th, 2004 09:57 AM
PublishObjects give Error 1004 TimP Excel VBA 1 June 16th, 2004 03:08 AM
DataGrid hyperlink column error burdickdave ASP.NET 1.x and 2.0 Application Design 3 February 26th, 2004 03:41 PM
Hiding and Resizing Column in MSHFlexGrid Dhodie VB How-To 1 September 21st, 2003 10:20 PM



All times are GMT -4. The time now is 03:31 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.