473,699 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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 1439
sombody plz....

David

"David Freeman" <no******@maili ngspam.com> wrote in message
news:eM******** ********@TK2MSF TNGP12.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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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 AutoGenerateCol umns 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******@maili ngspam.com> wrote in message
news:eM******** ******@TK2MSFTN GP12.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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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******@maili ngspam.com> skrev i en meddelelse
news:eM******** ********@TK2MSF TNGP12.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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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*******@hotm ail.com> skrev i en meddelelse
news:eA******** *****@TK2MSFTNG P11.phx.gbl...
Hi,

Set the AutoGenerateCol umns 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******@maili ngspam.com> wrote in message
news:eM******** ******@TK2MSFTN GP12.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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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*******@hotm ail.com> wrote in message
news:eA******** *****@TK2MSFTNG P11.phx.gbl...
Hi,

Set the AutoGenerateCol umns 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******@maili ngspam.com> wrote in message
news:eM******** ******@TK2MSFTN GP12.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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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.webs olver.dk> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
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******@maili ngspam.com> skrev i en meddelelse
news:eM******** ********@TK2MSF TNGP12.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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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******@maili ngspam.com> skrev i en meddelelse
news:eW******** ******@TK2MSFTN GP10.phx.gbl...
I'm hand-coding (with WebMatrix) so no properties page :P

Martin's method helped me.

Cheers,
David

"HG" <hg@nospam.webs olver.dk> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
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******@maili ngspam.com> skrev i en meddelelse
news:eM******** ********@TK2MSF TNGP12.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 OleDbDataAdapte r = Nothing

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

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

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

oleConn.Close()

With myDataGrid

.DataSource = objDataSet.Tabl es(strResultTab le)
.DataBind()

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

end with

I tried to hide the second column by...

.Columns(1).Vis ible = 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:BoundColum n DataField="Prio rity"
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
9921
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 (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
1
2530
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 new readonly textbox. If the selected cell it?s not readonly there?s no problem. I think that the problem it?s ralated with lose of focus of the datagrid. After pressing a button, I fill again the datagrid with new datasource but this thing...
2
1597
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 to 9. The idea is that if you push one of the numbers, it gets 'blown up' to the full size of the control, hiding all the other ones. It should also be possible to enable/disable some cells in the grid through calling a method. I've actually...
1
840
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 controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
9
3182
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 to change it to visible=true. You can't do that with a bound column (no ID), but you can create a templatecolumn with a label. To make these visible, I am going through each datagriditem and making them visible after I have bound the data to...
4
1807
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 have added some functionality where if the user right clicks the combobox a context menu will appear, saying "Fill the complete column with value 'XXX'". This value is the value they selected from the combobox. This is also working fine. However,...
5
3696
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 Identifier column so that I can run updates on the SqlAdapter object. Is there a way to hide this column from the datagrid? Dim dv1 As New DataView(ds.Tables("tbl1")) dv1.AllowNew = False dgr1.DataSource = dv1 '--dgr1 is the datagrid
4
3108
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 horizontally to view these coloumn names. So I want to group them into categories which will fit into a page. A user clicks a category and the category should
8
1982
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 button. There are a lot of fields across, and my Network Admins would like a way of editing/updating each issue seperately in a a vertical form. I need a way of clicking on the edit button ,bringing up a form with the record, editng the fields, and...
0
9178
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8885
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7752
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.