473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Trying to hide a datatable column from my datagrid... please help

I've read everywhere to use the following:

objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden

objDS.AcceptChanges()

dgNotes.DataSource = objDS.Tables("Results")

dgNotes.DataBind()

But, the column still shows? Can anyone shed some light on this?
Nov 17 '05 #1
4 13021
jonny,

I haven't seen any code like you're using before.

I hide columns by simply setting the column's visibility property.

Here's how I do it when I'm creating the datagrid myself:

<asp:boundcolumn visible="False" datafield="pk_EntryId"></asp:boundcolumn>

And here's how I set it from the codebehind:

DataGrid1.Columns(0).Visible = False

I hope this helps.
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"jonnylbluejeans" <jo*********@arch.com> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...
I've read everywhere to use the following:

objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden

objDS.AcceptChanges()

dgNotes.DataSource = objDS.Tables("Results")

dgNotes.DataBind()

But, the column still shows? Can anyone shed some light on this?

Nov 17 '05 #2
Perhaps your problem lies within the implementation of the DataGrid -
have you tried using bound columns instead of just databinding to the
default Grid?

-Christopher
http://weblogs.asp.net/CFrazier

jonnylbluejeans wrote:
I've read everywhere to use the following:


Nov 17 '05 #3
Use the ItemCreated Event to
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated

Select Case e.Item.ItemType

Case ListItemType.Header,ListItemType.AlternativeItem,L istItemType....

e.Item.Cells(1).Visible = False
End Sub
"jonnylbluejeans" <jo*********@arch.com> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...
I've read everywhere to use the following:

objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden

objDS.AcceptChanges()

dgNotes.DataSource = objDS.Tables("Results")

dgNotes.DataBind()

But, the column still shows? Can anyone shed some light on this?

Nov 17 '05 #4
Thanks for this one! It solved a different problem for me:

If I set a column's Visible property to False (unchecking in the columns
property page), the value read from it is empty. Using this technique makes
the column invisible without causing that side-effect.

Frankly, in the case of my problem, I think it's a bug!! But, whatever it
takes....

"Jerry" <JG******@rogers.com> wrote in message
news:jM*******************@news01.bloor.is.net.cab le.rogers.com...
Use the ItemCreated Event to
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemCreated

Select Case e.Item.ItemType

Case ListItemType.Header,ListItemType.AlternativeItem,L istItemType....

e.Item.Cells(1).Visible = False
End Sub
"jonnylbluejeans" <jo*********@arch.com> wrote in message
news:uE**************@TK2MSFTNGP12.phx.gbl...
I've read everywhere to use the following:

objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden

objDS.AcceptChanges()

dgNotes.DataSource = objDS.Tables("Results")

dgNotes.DataBind()

But, the column still shows? Can anyone shed some light on this?


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bajgon | last post by:
Hello, I have got a DataGrid and a DataTable, which is its DataSource. I can use DataTable.Rows.Find(key_value) method to locate any row in the DataTable, using values of key column. The...
3
by: tomi | last post by:
Hi I have following problem. I have a datatable filled with some data. Each row holds its ID (column named "Row_ID") DataTable dtTable; I have a datagrid to which I assign this datatable....
2
by: scott | last post by:
Hi all First off, thank you for any one that can help. I have a problem trying to link a DataGrideTableStyle to a DataGrid. I have a dataset which reads from a file a xml schema and a xml...
1
by: enak | last post by:
I populate a datagrid by setting the datasource to a datatable. I then, bind them. After that I try to hide the last column but am not able to. I get an error message. Here is my code: ...
8
by: Hanson | last post by:
I have a datagrid control in an aspx page. The datagrid columns will be dynamically generated according to the pre-page's search condition, I want to hide some columns in the datagrid. is that...
3
by: Tim::.. | last post by:
I currently have the following datagrid but want to turn the name and email column into a hyperlink in the codebehind! Can someone please tell me how I achieve this! Thanks Private Sub...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
5
by: =?Utf-8?B?S3VuYWwgUGF0ZWw=?= | last post by:
I have a DataTable with Column DataType as Double I just want to show data in C# datagrid with two decimal places which property do I set for DataColum of DataTable and How? Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.