Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Data grid columns still showing up

Reply
Thread Tools

Data grid columns still showing up

 
 
Angel Fernendez
Guest
Posts: n/a
 
      11-21-2003
I am using a run-time connection to populate a datagrid and when I try to
hide my columns it does not work. If I set the column index higher I get an
error.

here is the code

cn.Open();

SqlCommand cmd = new SqlCommand(sSQL,cn);

DataTable dt = new DataTable();

SqlDataAdapter da = new SqlDataAdapter(cmd);

da.Fill(dt);

DataGrid1.DataSource = dt;

DataGrid1.DataBind();

this.DataGrid1.Columns[1].Visible = false;

does anyone have any suggestions?
Please help!!

Thanks!!


 
Reply With Quote
 
 
 
 
source
Guest
Posts: n/a
 
      12-29-2003
According to MSDN, you can only manipulate (specially using the visible
property) only the explicitly declared columns. If you have
'AutoGenerateColumns' = 'True' for your datagrid then you wont be able to
use the Columns collection for the datagrid.
Even I am trying to hide a column which is not explicitly declared.

Anybody who knows how to hide a column which is not explicitly declared let
me know.

"Angel Fernendez" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am using a run-time connection to populate a datagrid and when I try to
> hide my columns it does not work. If I set the column index higher I get

an
> error.
>
> here is the code
>
> cn.Open();
>
> SqlCommand cmd = new SqlCommand(sSQL,cn);
>
> DataTable dt = new DataTable();
>
> SqlDataAdapter da = new SqlDataAdapter(cmd);
>
> da.Fill(dt);
>
> DataGrid1.DataSource = dt;
>
> DataGrid1.DataBind();
>
> this.DataGrid1.Columns[1].Visible = false;
>
> does anyone have any suggestions?
> Please help!!
>
> Thanks!!
>
>



 
Reply With Quote
 
 
 
 
Greg Baugher
Guest
Posts: n/a
 
      01-28-2004
I have a column in a datagrid that I don't want displayed, but still need
access to the data. I changed the column width in the DataGridTableStyle.

"source" <(E-Mail Removed)> wrote in message
news:e$(E-Mail Removed)...

> According to MSDN, you can only manipulate (specially using the visible
> property) only the explicitly declared columns. If you have
> 'AutoGenerateColumns' = 'True' for your datagrid then you wont be able to
> use the Columns collection for the datagrid.
> Even I am trying to hide a column which is not explicitly declared.
>
> Anybody who knows how to hide a column which is not explicitly declared

let
> me know.
>
> "Angel Fernendez" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I am using a run-time connection to populate a datagrid and when I try

to
> > hide my columns it does not work. If I set the column index higher I get

> an
> > error.
> >
> > here is the code
> >
> > cn.Open();
> >
> > SqlCommand cmd = new SqlCommand(sSQL,cn);
> >
> > DataTable dt = new DataTable();
> >
> > SqlDataAdapter da = new SqlDataAdapter(cmd);
> >
> > da.Fill(dt);
> >
> > DataGrid1.DataSource = dt;
> >
> > DataGrid1.DataBind();
> >
> > this.DataGrid1.Columns[1].Visible = false;
> >
> > does anyone have any suggestions?
> > Please help!!
> >
> > Thanks!!
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with dynamic template columns in a data grid =?Utf-8?B?U2ltb24=?= ASP .Net 1 11-22-2007 09:28 AM
Adding columns dynamically to data grid Roger Frei ASP .Net 2 06-15-2007 11:48 AM
Showing data with no fixed columns in datatable with JSF... gbattine Java 0 07-06-2006 09:08 AM
Data Grid - Update Columns Ryan Ternier ASP .Net 2 02-16-2005 04:39 PM
Exporting data from (All columns in data grid EXCEPT THE 1st) to E =?Utf-8?B?cG11ZA==?= ASP .Net 2 01-10-2005 07:53 PM



Advertisments