Setting Datagrid Column to invisible when Column is an AutoGeneratedColumn NOT a bound Column

Hi all,

Just like the title says, I'm trying to set a column to invisible but I'm unable to do so.
If I bound the column I can used the code:

me.datagrid.Column.Item(1).Visible = False

But since I'm wanting the column NOT to be bound (there are a number of sql scripts that populate the same datagrid so I cannot bound all the columns since the columns are different for each script etc etc etc) how do I set an AutoGeneratedColumn to invisible??
Please help!
Andrew
www.codingmayhem.com - VB.NET, C#, Silverlight, Javascript, HTML, CSS, T-SQL, MySQL and SQLite
www.headshotgamer.com - Gaming News and Reviews
0
andrewphq
5/26/2004 12:58:59 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

7 Replies
1214 Views

Similar Articles

[PageSpeed] 46

0
andrewphq
5/26/2004 11:11:10 PM
Doesn't the following work for setting a specific column's visibility on or off regardless of whether or not the column is bound or autogenerated.  



mydg.Columns[1].Visible=false;

Where mydg is the datagrid id and 1 is the column that you are trying to make invisible.
I have not tried this approach but something like this might work too.

mydg.Columns["productid"].Visible=false;

Where productid is the field whose column you want to be invisible.
Sam (C# Newbie)
0
froman21
5/27/2004 1:44:53 AM
Cheers for your input, but alas I've tried that already and it doesn't work.

Can anyone else lend a hand?
www.codingmayhem.com - VB.NET, C#, Silverlight, Javascript, HTML, CSS, T-SQL, MySQL and SQLite
www.headshotgamer.com - Gaming News and Reviews
0
andrewphq
5/27/2004 5:29:13 AM

Hi,
I am also stuck with this right now.
It works with columns(0) but not with columns(1) !!!
I get the error : ArgumentOutOfRangeException
Johann
Website - Weblog
0
jfrot
5/27/2004 10:08:08 AM
I did a check using an autogencolumn datagrid and used the 


lbl_colcount.text=mydg.columns.count.tostring();

just to see why i was always getting an index out of range message. The result was a 0.
That is why the columns cannot be identified as I suggested above. I know that this would be a round about way of handling it (what programming isnt), but can you just modify the datasource before binding to the datagrid so that the column would never be generated anyway?
0
froman21
5/27/2004 5:00:00 PM
0
andrewphq
5/31/2004 12:31:11 AM
Last chance before this lives on the Escalation Queue...

Someone please advise!! There MUST be an easy way!!
Cheers again
Andrew
www.codingmayhem.com - VB.NET, C#, Silverlight, Javascript, HTML, CSS, T-SQL, MySQL and SQLite
www.headshotgamer.com - Gaming News and Reviews
0
andrewphq
6/1/2004 5:30:33 AM
Reply:

Similar Artilces:

When is a column not a column?
I have several extremely similar datawindows that I have to maintain that go against the same table. Recently, I had to add a column to that table, and also add the column to ALL of these datawindows that go against this table. I added the column to the first datawindow, set up the edit control style, etc. I then did a copy/paste of the columns edit control to the remaining dw's (of course remembering to first add the column in SQL). Everything (update props, column specs, column props) seems to indicate that the pasted column is linked to the column I selected, HOWEVER, when I...

Datagrid Bound Column needs to be bound to 2 columns?a valu
Hi I have a datagrid with dynamically bounded columns. One column has to display a value that will come from 2 columns in the database. Is there a way to do this? the code I have for the moment is: 'Add columns 'Code Dim col1 As New BoundColumn col1.HeaderText = cLang.read("code") col1.DataField = "Patient_Code" 'this needs to be 2 database columns!! dtaSearchresult.Columns.Add(col1) .. .. .. .. Thx alot! Combine the two columns in your SELECT statement eg SELECT <PatientCol1>+<PatientCol2> AS Patient_Code FR...

in a grid how to find a particular column is bound column or template column
hi,  Any one know how to find a particular column is bound column or template column or button column,etc in a grid Advance thanks   hi...use this dim label1 as Label=ctype(GridView1.FindControl("name"),Label) Hope This HelpsBhaaratRemember to click "Mark as Answer" on the post that helps UMy Blog find a particular column is bound column or template column no to find that particular column  Hi,please excuse me if iam wrong.i found that bount columns values are directly renders to a <td>  where template columns create some cont...

DataGrid: Bound Column vs Template Column
I have a datagrid with a bound column and a template column as given below.When I scan through the grid, I get the value of the first column (bound column). However, I cannot get the value of the second column (Template Column). I can see the data in both columns though.////////////////////////////////////////////////////////////////////////////////////<AlternatingItemStyle BackColor="#e0e0e0"></AlternatingItemStyle><Columns><asp:BoundColumn DataField="Facility" HeaderText="Facility"> </asp:BoundColumn><asp:TemplateColumn HeaderText="Facility2"><ItemSty...

datagrid columns bound to columns from different tables
Hi, I have a dataset with multiple tables. Is there a way to bind each of the datagrid's columns to a column from a different tables? Thanks in advance! BR The bottom line, yes you can, but it would take some custom methods getting called from a template column and some other fancy tricks. But, the datagrid is designed and works best when it's given it's one datasource. If you need data from different columns in different tables, I would make a custom datatable that reflects the columns you need and use that custom datatable has the datagrid's datasource. Don't think of t...

Column within a column in a DataGrid
Hi, I have a DataGrid on which I would like to divide a particular column into 2 to display a number information on the sub column?? Visually I'm speaking something like this below. +----------------+-----------------+ | ACCOUNTID | ACCOUNT NO | +----------------+-----------------+ | 1000 | | 125364 | | 1015 | | 125365 | | 1025 | | 125312 | +-----------------+----------------+ My question again is how to see this extra sub column within the ACCOUNTID Column here. Looking for a quick reply. Th...

IF you set column to width 0 in a datawindow grid, the column appear as a with column at the end of the grid
Can you remove the white space at the end of a grid, it seems to appear when we set columnwidths to '0'.. ICE I've not seen that. What version of PB are you using? What platform? On Tue, 27 Aug 2002 11:42:02 +0200, in powersoft.public.powerbuilder.datawindow ICE <ICE@nospam.com> wrote: >Can you remove the white space at the end of a grid, it seems to appear when >we set columnwidths to '0'.. > > >ICE > > Bruce Armstrong [TeamSybase] http://www.teamsybase.com Not 1 - but 2 new books on developing with PowerBuilder...

Export DataGrid to Excel
Hi,  I am working on a function of exporting DataGrid to excel with following coding: protected override void Render(HtmlTextWriter writer) {Response.ContentType = "application/ms-excel"; Response.AddHeader("Content-Disposition", "inline;filename=test.xls"); DataTable dt = new DataTable(); ... DataGrid2.DataSource = dt; DataGrid2.DataBind(); DataGrid2.RenderControl(writer); } I would like to set the column width at certain Excel column. However, the width cannot be controlled by setting the column width of DataGrid. Any methods to this?   ...

datagrid with dropdownlist in a column
Hi, I am attempting to set the data in 2 template columns based on the selectedIndexValue of the dropdownlist. I am capturing the selectedindexchanged event and using that. The problem occurs when I attempt to use the value in the dropdownlist as an argument for the stored procedure that needs to run to retrieve the needed data for the other 2 columns. Any Suggestions? -Laeros  Here is my code...Public Sub dgDropDownProjects_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgUserList.SelectedIndexChanged Dim strConn As String strConn = ...

Issue with Template Columns & Bound Columns while updating the data in a GridView control
Hi, I'm facing the below problem (In general, ObjectDataSource is driving me crazy ! ) I have a simple gridview control and an ObjectDataSource is used to populate the grid. I'm trying to update a row and the corresponding tableadapter methods & stored procedure are in place. Each row has 2 checkboxes and 2 textboxes in edit mode. When the change the values in edit mode and hit update, the checkbox values changed are saved into the Database properly, whereas the textbox values are not being saved. If the textbox column is a bound column then the column is updated with <NULL> in...

Dynamic change the 'Read Only' in datagrid(template column/Bound column)
I create few template column and bound column in datagrid. One of the template column contain the StudentMark. I want to know how to change that column to (Read only) or "Not" (Read only) when click the edit button. It is based on a dropdownlist to determine to read only or not. I think i must use the template column, since i need to do the validation to the StudentMark. (For example, If select value '1' in dropdownlist, the "StudentMark" is become 'Read only' and select '2' become vice versa. I was success to bind the datagrid and "StudentMark" become a textbox...

How to subtract two date columns(bound) of a Datagrid and display the result in the third column?
Hi Everyone,I  have two date columns(databound-coming from SQL database) in my datagrid, 'start date' & 'end date'. I need to calculate number of days with 'end date- start date' and display the result in the third datagrid column. i.e.: column2-column1 = column3Any help anyone?...ASAP please got a deadline to meet :) (SOS!!!)Many Thanks in advance,Arty.Aartee...we live more than once! Hi, there are several ways of doing it. One of them is creating a label in the TemplateColumn, use the Helper function to calculate the number of days.<ItemTemplate>   <...

How to subtract two numeric columns(bound) of a Datagrid and display the result in the third column?
Hi Everyone,I  have two numeric columns(databound-coming from SQL database) in my datagrid, 'PromoPrice' & 'CostPrice'. I need to calculate 'PromoPrice- CostPrice' and display the result in the third datagrid column. i.e.: column2-column1 = column3Any help anyone...Many Thanks in advance,Nico. In your query do this:Select .... , (PromoPrice - CostPrice) AS Answer, .....FROM yourTableKeep in mind you can do math functions in queries.DarmarkMark as Answer, if this reply answers your post. Hi Darmark, thanks for your fast answer.The fact is I'm using a single "select function"...

Setting a Datagrid Column to invisible
Hi everyone, I'm trying in vain to set a datagrids column to invisible. The first column (0) is an "Edit" link. The rest are created depending on what script it run (as in they're not bound - they're dynamic if that makes sense). Anyway, here's my code attempts: Me.DataGrid.Columns.Item(0).Visible = False 'This works hiding the "Edit" link Me.DataGrid.Columns.Item(1).Visible = False 'This gives a run time error * Me.DataGrid.Columns(1).Visible = False 'This gives a run time error * Me.DataGrid.Columns(1).Visible = Not (Me.Data...

Web resources about - Setting Datagrid Column to invisible when Column is an AutoGeneratedColumn NOT a bound Column - asp.net.presentation-controls

Resources last updated: 11/29/2015 9:52:13 PM