473,427 Members | 1,640 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,427 software developers and data experts.

DataGrid - Hiding a Column - Not Working

Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY [Country],
[Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David
Nov 18 '05 #1
7 1424
sombody plz....

David

"David Freeman" <no******@mailingspam.com> wrote in message
news:eM****************@TK2MSFTNGP12.phx.gbl...
Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY [Country],
[Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David

Nov 18 '05 #2
Hi,

Set the AutoGenerateColumns property (attribute) of the DataGrid to false
and add only the columns you need to be displayed (rendered) to the client.

Hope this helps
Martin Dechev
ASP.NET MVP
"David Freeman" <no******@mailingspam.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY [Country],
[Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David

Nov 18 '05 #3
HG
Hi David

Are your columns generated at runtime (this neat little checkbox on the
datagrid properties page)?
If so, try unchecking it, and adding your columns manually (in the
properties page)

Another options that might work (dunno for sure), is to move the setting of
Visible = False to before the call to DataBind.
This might give you a runtime exception..not sure.

HTH
/HG
"David Freeman" <no******@mailingspam.com> skrev i en meddelelse
news:eM****************@TK2MSFTNGP12.phx.gbl...
Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY [Country],
[Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David

Nov 18 '05 #4
HG
YO! Martin

Got me there. Just a little earlier than my post.

"Martin Dechev" <de*******@hotmail.com> skrev i en meddelelse
news:eA*************@TK2MSFTNGP11.phx.gbl...
Hi,

Set the AutoGenerateColumns property (attribute) of the DataGrid to false
and add only the columns you need to be displayed (rendered) to the client.
Hope this helps
Martin Dechev
ASP.NET MVP
"David Freeman" <no******@mailingspam.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY [Country], [Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David


Nov 18 '05 #5
Thanks!!!

David

"Martin Dechev" <de*******@hotmail.com> wrote in message
news:eA*************@TK2MSFTNGP11.phx.gbl...
Hi,

Set the AutoGenerateColumns property (attribute) of the DataGrid to false
and add only the columns you need to be displayed (rendered) to the
client.

Hope this helps
Martin Dechev
ASP.NET MVP
"David Freeman" <no******@mailingspam.com> wrote in message
news:eM**************@TK2MSFTNGP12.phx.gbl...
Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY
[Country],
[Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David


Nov 18 '05 #6
I'm hand-coding (with WebMatrix) so no properties page :P

Martin's method helped me.

Cheers,
David

"HG" <hg@nospam.websolver.dk> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
Hi David

Are your columns generated at runtime (this neat little checkbox on the
datagrid properties page)?
If so, try unchecking it, and adding your columns manually (in the
properties page)

Another options that might work (dunno for sure), is to move the setting
of
Visible = False to before the call to DataBind.
This might give you a runtime exception..not sure.

HTH
/HG
"David Freeman" <no******@mailingspam.com> skrev i en meddelelse
news:eM****************@TK2MSFTNGP12.phx.gbl...
Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY
[Country],
[Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " +
"Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David


Nov 18 '05 #7
HG
Hi David

Martins and mine methods does the same thing - in two different ways -
non-GUI and GUI.

Glad to help.


"David Freeman" <no******@mailingspam.com> skrev i en meddelelse
news:eW**************@TK2MSFTNGP10.phx.gbl...
I'm hand-coding (with WebMatrix) so no properties page :P

Martin's method helped me.

Cheers,
David

"HG" <hg@nospam.websolver.dk> wrote in message
news:%2******************@TK2MSFTNGP14.phx.gbl...
Hi David

Are your columns generated at runtime (this neat little checkbox on the
datagrid properties page)?
If so, try unchecking it, and adding your columns manually (in the
properties page)

Another options that might work (dunno for sure), is to move the setting
of
Visible = False to before the call to DataBind.
This might give you a runtime exception..not sure.

HTH
/HG
"David Freeman" <no******@mailingspam.com> skrev i en meddelelse
news:eM****************@TK2MSFTNGP12.phx.gbl...
Hi There!

Below is my VB.NET code...

Dim strSQL As String

strSQL = "SELECT [Name],[Priority] FROM Customers GROUP BY
[Country],
[Priority], [Name]"

Dim oleConn As OleDbConnection = Nothing
Dim oleAdapter As OleDbDataAdapter = Nothing

Dim objDataSet As DataSet = Nothing
Dim strResultTable As String = "Customers"

oleConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + Server.MapPath("Test.mdb"))

oleAdapter = New OleDbDataAdapter(strSQL, oleConn)
objDataSet = New DataSet
oleAdapter.Fill(objDataSet, strResultTable)

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tables(strResultTable)
.DataBind()

.Columns(1).Visible = False '<< Not Working!!!!

end with

I tried to hide the second column by...

.Columns(1).Visible = False

But the column does not hide! Why?

I've also tried the following in my HTML section...

<asp:DataGrid runat="server" id="myDataGrid">

<Columns>
<asp:BoundColumn DataField="Priority"
Visible="False"></asp:BoundColumn>
</Columns>

</asp:DataGrid>

And still the column does not hide.

This is driving me nuts! Plz help!!!!

Thank you all in advance!

David



Nov 18 '05 #8

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

Similar topics

2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
1
by: Paulo Gon?alves via .NET 247 | last post by:
My datagrid has a big problem, it happens only in columns that are read only. Please see the picture at http://mega.ist.utl.pt/~pfrg/datagrid/datagrid_problem.jpg The gost that I show it?s like a...
2
by: news | last post by:
Hello All, As a VB6/C/C++ (and some Java) developer, I've been toying with c# for the last couple of weeks. I'm currently trying to create a grid of 3x3 with each cell containing numbers from 1...
1
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems...
9
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens...
4
by: Anthony | last post by:
Hi Folks, I'm adding some columns to my datagrid which are of Combo Box type. I'm inheriting DataGridTextBoxColumn and doing all the usual stuff to get them populated. This is working fine. I...
5
by: Rich | last post by:
I have a datagrid that uses a dataview object for its datasource. The dataview contains a unique row identifier column. I don't want to display this column in the datagrid. I need the unique row...
4
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll...
8
by: =?Utf-8?B?bWlrZWc=?= | last post by:
Hi, I am building a small Help Desk application for my company and need to be able to edit "open" help desk issues. I use a simple datagrid to display each issue (6 per page) , with an Edit...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.