By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

DataGrid - Hiding a Column - Not Working

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.