Hi,
Code attached but the line that gives me an error is
MyDataGrid.Columns(2).Visible = False
It actually gives me an error for any value instead of 2 even when 9 bound
columns of data exist. How do i hide a column? Thanks.
MyConnection = New
SqlConnection("server=(local);database=pubs;Truste d_Connection=yes")
MyCommand = New SqlDataAdapter("select * from Authors",
MyConnection)
DS = New DataSet
MyCommand.Fill(DS, "Authors")
MyDataGrid.DataSource = DS.Tables("Authors").DefaultView
MyDataGrid.DataBind()
MyDataGrid.BackColor = Color.White
MyDataGrid.BorderColor = Color.Violet
MyDataGrid.BorderStyle = BorderStyle.Dotted
MyDataGrid.ToolTip = "JBs table"
'!!!!!!Error line - out of range althought there are 9 columns.
MyDataGrid.Columns(2).Visible = False
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700"
BackColor="#ccccff" BorderColor="black"
ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana"
Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
EnableViewState="false" /> 15 3730
Since you know that you want to hide Col.2 why dont you set it to
visible=false during the design time?
Hth...
R. Thomas
"John Blair" wrote: Hi,
Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist. How do i hide a column? Thanks.
MyConnection = New SqlConnection("server=(local);database=pubs;Truste d_Connection=yes") MyCommand = New SqlDataAdapter("select * from Authors", MyConnection)
DS = New DataSet MyCommand.Fill(DS, "Authors")
MyDataGrid.DataSource = DS.Tables("Authors").DefaultView MyDataGrid.DataBind() MyDataGrid.BackColor = Color.White MyDataGrid.BorderColor = Color.Violet MyDataGrid.BorderStyle = BorderStyle.Dotted MyDataGrid.ToolTip = "JBs table"
'!!!!!!Error line - out of range althought there are 9 columns. MyDataGrid.Columns(2).Visible = False
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false" />
Thanks for feedback....but as its databound the column does not exist at
design time only run-time! Therefore im looking for a run-time way of hiding
the data (i want to associate data with the row but not show it to the user)
...in case you were going to just say remove it from the SQL statement!
Thanks.
"R. Thomas, aka Xtreme.Net" <NoSpam(Xt**********@hotmail.com.NoSpam> wrote
in message news:EF**********************************@microsof t.com... Since you know that you want to hide Col.2 why dont you set it to visible=false during the design time? Hth... R. Thomas
"John Blair" wrote:
Hi,
Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist. How do i hide a column? Thanks.
MyConnection = New SqlConnection("server=(local);database=pubs;Truste d_Connection=yes") MyCommand = New SqlDataAdapter("select * from Authors", MyConnection)
DS = New DataSet MyCommand.Fill(DS, "Authors")
MyDataGrid.DataSource = DS.Tables("Authors").DefaultView MyDataGrid.DataBind() MyDataGrid.BackColor = Color.White MyDataGrid.BorderColor = Color.Violet MyDataGrid.BorderStyle = BorderStyle.Dotted MyDataGrid.ToolTip = "JBs table"
'!!!!!!Error line - out of range althought there are 9 columns. MyDataGrid.Columns(2).Visible = False
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false" />
Ofcource, No one will ever suggest to remove the col from SQL..
But here is something you can try..
Check if there is actually some data in the datagrid before you try to hide
the col.
Lemme know if there is any data is the datagrid when u are trying to hide
the col.
Hth..
R. Thomas
"John Blair" wrote: Thanks for feedback....but as its databound the column does not exist at design time only run-time! Therefore im looking for a run-time way of hiding the data (i want to associate data with the row but not show it to the user) ...in case you were going to just say remove it from the SQL statement! Thanks.
"R. Thomas, aka Xtreme.Net" <NoSpam(Xt**********@hotmail.com.NoSpam> wrote in message news:EF**********************************@microsof t.com... Since you know that you want to hide Col.2 why dont you set it to visible=false during the design time? Hth... R. Thomas
"John Blair" wrote:
Hi,
Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist. How do i hide a column? Thanks.
MyConnection = New SqlConnection("server=(local);database=pubs;Truste d_Connection=yes") MyCommand = New SqlDataAdapter("select * from Authors", MyConnection)
DS = New DataSet MyCommand.Fill(DS, "Authors")
MyDataGrid.DataSource = DS.Tables("Authors").DefaultView MyDataGrid.DataBind() MyDataGrid.BackColor = Color.White MyDataGrid.BorderColor = Color.Violet MyDataGrid.BorderStyle = BorderStyle.Dotted MyDataGrid.ToolTip = "JBs table"
'!!!!!!Error line - out of range althought there are 9 columns. MyDataGrid.Columns(2).Visible = False
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false" />
This is the first time to give solutions. If any mistakes pls execuse
me.
First, what are the rows u want ot hide,
Using DataTable.Select('condition','order by columns');
Or
Using DataView.Filter() methods you can hide the values.
Thanks for the reply - but i am trying to hide a column not a row.
I want to show ALL rows but only certain columns.
It appears that the nine databount columns dont appear in the
datagrid.columns.count - it shows as 0 instead of 9.
Thanks.
"Ramesh" <na**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... This is the first time to give solutions. If any mistakes pls execuse me.
First, what are the rows u want ot hide, Using DataTable.Select('condition','order by columns'); Or Using DataView.Filter() methods you can hide the values.
Hi,
There are 23 rows of data in 9 columns but the columns.count is still
showing as 0 - it doesnt seem to synchronsize with the databound data!
thanks.
"R. Thomas, aka Xtreme.Net" <NoSpam(Xt**********@hotmail.com.NoSpam> wrote
in message news:24**********************************@microsof t.com... Ofcource, No one will ever suggest to remove the col from SQL.. But here is something you can try.. Check if there is actually some data in the datagrid before you try to hide the col. Lemme know if there is any data is the datagrid when u are trying to hide the col. Hth.. R. Thomas
"John Blair" wrote:
Thanks for feedback....but as its databound the column does not exist at design time only run-time! Therefore im looking for a run-time way of hiding the data (i want to associate data with the row but not show it to the user) ...in case you were going to just say remove it from the SQL statement! Thanks.
"R. Thomas, aka Xtreme.Net" <NoSpam(Xt**********@hotmail.com.NoSpam> wrote in message news:EF**********************************@microsof t.com... > Since you know that you want to hide Col.2 why dont you set it to > visible=false during the design time? > Hth... > R. Thomas > > > "John Blair" wrote: > >> Hi, >> >> Code attached but the line that gives me an error is >> MyDataGrid.Columns(2).Visible = False >> It actually gives me an error for any value instead of 2 even when 9 >> bound >> columns of data exist. How do i hide a column? Thanks. >> >> MyConnection = New >> SqlConnection("server=(local);database=pubs;Truste d_Connection=yes") >> MyCommand = New SqlDataAdapter("select * from Authors", >> MyConnection) >> >> DS = New DataSet >> MyCommand.Fill(DS, "Authors") >> >> >> MyDataGrid.DataSource = DS.Tables("Authors").DefaultView >> MyDataGrid.DataBind() >> MyDataGrid.BackColor = Color.White >> MyDataGrid.BorderColor = Color.Violet >> MyDataGrid.BorderStyle = BorderStyle.Dotted >> MyDataGrid.ToolTip = "JBs table" >> >> '!!!!!!Error line - out of range althought there are 9 >> columns. >> MyDataGrid.Columns(2).Visible = False >> >> >> <ASP:DataGrid id="MyDataGrid" runat="server" Width="700" >> BackColor="#ccccff" BorderColor="black" >> ShowFooter="false" CellPadding="3" CellSpacing="3" >> Font-Name="Verdana" >> Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" >> EnableViewState="false" /> >> >> >> >> >>
Hi Ramesh, when u user Select or Filter, what you are doin is that you are
seperating the values that you need.
But I believe the purpose of John is to use the hidden col for ID purposes
etc..
"Ramesh" wrote: This is the first time to give solutions. If any mistakes pls execuse me.
First, what are the rows u want ot hide, Using DataTable.Select('condition','order by columns'); Or Using DataView.Filter() methods you can hide the values.
See, now that is exactly what I was asking, if you have something in the
datagrid to start with.
Now that you know that there is nothin in the datagrid, the error must have
become obvious - there are no cols that you can hide.
I hope now you have got the root cause of ur prob and can rectify it easily
P.S: If this thread was usefull to you, pls click 'Yes' on the top.
Hth..
R. Thomas
"John Blair" wrote: Thanks for the reply - but i am trying to hide a column not a row. I want to show ALL rows but only certain columns. It appears that the nine databount columns dont appear in the datagrid.columns.count - it shows as 0 instead of 9.
Thanks.
"Ramesh" <na**********@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... This is the first time to give solutions. If any mistakes pls execuse me.
First, what are the rows u want ot hide, Using DataTable.Select('condition','order by columns'); Or Using DataView.Filter() methods you can hide the values.
Tnanks for the feedback but sorry - i dont believe you understand my
problem.
The grid has no rows or columns initially because it is a databound one.
Once bound via SQL statement there are 23 rows 9 columns.
After data binding i.e. MyDataGrid.DataBind() i want to hide one of those
columns
- i cant do it by making e.g. column(2).visible = false because
..columns.count is still 0.
Hope this is clearer....thanks anyway.
"R. Thomas, aka Xtreme.Net" <NoSpam(Xt**********@hotmail.com.NoSpam> wrote
in message news:15**********************************@microsof t.com... See, now that is exactly what I was asking, if you have something in the datagrid to start with. Now that you know that there is nothin in the datagrid, the error must have become obvious - there are no cols that you can hide. I hope now you have got the root cause of ur prob and can rectify it easily P.S: If this thread was usefull to you, pls click 'Yes' on the top. Hth.. R. Thomas "John Blair" wrote:
Thanks for the reply - but i am trying to hide a column not a row. I want to show ALL rows but only certain columns. It appears that the nine databount columns dont appear in the datagrid.columns.count - it shows as 0 instead of 9.
Thanks.
"Ramesh" <na**********@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr oups.com... > This is the first time to give solutions. If any mistakes pls execuse > me. > > First, what are the rows u want ot hide, > Using DataTable.Select('condition','order by columns'); > Or > Using DataView.Filter() methods you can hide the values. >
The reason for the error you are getting is that autogenerated columns are
not getting to Columns collection. You have 2 ways of solving the problem.
1. Add the columns in design time. Then you will find them in Columns
collection.
2. Even if the columns are autogenerated, you can handle ItemCreated event
in code-behind. Items corresponds to rows. In the event handler you can
access the cells of the rows you want to hide and make them invisible either
by setting Visible property or by setting a css style rule display:none.
Eliyahu
"John Blair" <jo********@hotmail.com> wrote in message
news:SH*************@newsfe1-gui.ntli.net... Hi,
Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist. How do i hide a column? Thanks.
MyConnection = New SqlConnection("server=(local);database=pubs;Truste d_Connection=yes") MyCommand = New SqlDataAdapter("select * from Authors", MyConnection)
DS = New DataSet MyCommand.Fill(DS, "Authors")
MyDataGrid.DataSource = DS.Tables("Authors").DefaultView MyDataGrid.DataBind() MyDataGrid.BackColor = Color.White MyDataGrid.BorderColor = Color.Violet MyDataGrid.BorderStyle = BorderStyle.Dotted MyDataGrid.ToolTip = "JBs table"
'!!!!!!Error line - out of range althought there are 9 columns. MyDataGrid.Columns(2).Visible = False
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false" />
Very impressed thanks a lot - i chose to use your second method using the
itemcreated event.
Code used to hide the first column for the others who posted to this
subject.
<ASP:DATAGRID id="MyDataGrid" runat="server" OnItemCreated="Item_Created"
....
</ASP:DATAGRID>
Sub Item_Created(sender As Object, e As DataGridItemEventArgs)
e.item.cells(0).visible = false
End Sub 'Item_Created
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... The reason for the error you are getting is that autogenerated columns are not getting to Columns collection. You have 2 ways of solving the problem.
1. Add the columns in design time. Then you will find them in Columns collection.
2. Even if the columns are autogenerated, you can handle ItemCreated event in code-behind. Items corresponds to rows. In the event handler you can access the cells of the rows you want to hide and make them invisible either by setting Visible property or by setting a css style rule display:none.
Eliyahu
"John Blair" <jo********@hotmail.com> wrote in message news:SH*************@newsfe1-gui.ntli.net... Hi,
Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist. How do i hide a column? Thanks.
MyConnection = New SqlConnection("server=(local);database=pubs;Truste d_Connection=yes") MyCommand = New SqlDataAdapter("select * from Authors", MyConnection)
DS = New DataSet MyCommand.Fill(DS, "Authors")
MyDataGrid.DataSource = DS.Tables("Authors").DefaultView MyDataGrid.DataBind() MyDataGrid.BackColor = Color.White MyDataGrid.BorderColor = Color.Violet MyDataGrid.BorderStyle = BorderStyle.Dotted MyDataGrid.ToolTip = "JBs table"
'!!!!!!Error line - out of range althought there are 9 columns. MyDataGrid.Columns(2).Visible = False
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false" />
John:
I believe the column count is always 0 if the grid is set to
autogenerate columns...
--
Scott http://www.OdeToCode.com/blogs/scott/
On Mon, 27 Dec 2004 11:58:22 GMT, "John Blair"
<jo********@hotmail.com> wrote: Hi,
There are 23 rows of data in 9 columns but the columns.count is still showing as 0 - it doesnt seem to synchronsize with the databound data!
thanks.
unless you add some columns manually
Eliyahu
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:c3********************************@4ax.com... John:
I believe the column count is always 0 if the grid is set to autogenerate columns...
-- Scott http://www.OdeToCode.com/blogs/scott/
On Mon, 27 Dec 2004 11:58:22 GMT, "John Blair" <jo********@hotmail.com> wrote:
Hi,
There are 23 rows of data in 9 columns but the columns.count is still showing as 0 - it doesnt seem to synchronsize with the databound data!
thanks.
hi,
The solution is simple go to itembound event and put this line
e.item.cells(0).visible = false
It is advisable to make visiblity and stuff in Item databound event
If you r using .net IDE
The second option is to go to the property builder and set the visible check
box of column in columns
happy coding
Regards,
Mehta Rahul
"John Blair" wrote: Very impressed thanks a lot - i chose to use your second method using the itemcreated event. Code used to hide the first column for the others who posted to this subject.
<ASP:DATAGRID id="MyDataGrid" runat="server" OnItemCreated="Item_Created" .... </ASP:DATAGRID>
Sub Item_Created(sender As Object, e As DataGridItemEventArgs)
e.item.cells(0).visible = false
End Sub 'Item_Created "Eliyahu Goldin" <re*************@monarchmed.com> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... The reason for the error you are getting is that autogenerated columns are not getting to Columns collection. You have 2 ways of solving the problem.
1. Add the columns in design time. Then you will find them in Columns collection.
2. Even if the columns are autogenerated, you can handle ItemCreated event in code-behind. Items corresponds to rows. In the event handler you can access the cells of the rows you want to hide and make them invisible either by setting Visible property or by setting a css style rule display:none.
Eliyahu
"John Blair" <jo********@hotmail.com> wrote in message news:SH*************@newsfe1-gui.ntli.net... Hi,
Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist. How do i hide a column? Thanks.
MyConnection = New SqlConnection("server=(local);database=pubs;Truste d_Connection=yes") MyCommand = New SqlDataAdapter("select * from Authors", MyConnection)
DS = New DataSet MyCommand.Fill(DS, "Authors")
MyDataGrid.DataSource = DS.Tables("Authors").DefaultView MyDataGrid.DataBind() MyDataGrid.BackColor = Color.White MyDataGrid.BorderColor = Color.Violet MyDataGrid.BorderStyle = BorderStyle.Dotted MyDataGrid.ToolTip = "JBs table"
'!!!!!!Error line - out of range althought there are 9 columns. MyDataGrid.Columns(2).Visible = False
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" EnableViewState="false" />
This is the first time to give solutions. If any mistakes pls execuse
me.
First, what are the rows u want ot hide,
Using DataTable.Select('condition','order by columns');
Or
Using DataView.Filter() methods you can hide the values. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fresh Air Rider |
last post by:
Hi
Could anyone please give me the syntax for calling a function with
more than one parameter from an <asp:LinkButton> ?
Many thanks
John
|
by: z. f. |
last post by:
Hi,
i stated that this is an advanced question because i have a post from few
days ago that i received answers to with suggestions that looked good but
did not work, so please if you post a...
|
by: roni |
last post by:
in datagrid control , how can i change the width of textbox in edit mode (on
<asp:BoundColumn> ) ?
|
by: Satya |
last post by:
Hi all,
The following code is throwing a run time error "The server tag is not well
formed.
"
<ItemTemplate>
<asp:HyperLink Runat="server" ID="lnkFile"...
|
by: John Smith |
last post by:
This is what I am trying to do:
<asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn Visible="False" DataField="id" ReadOnly="True"...
|
by: John Smith |
last post by:
This is what I am trying to do:
<asp:datagrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn Visible="False" DataField="id" ReadOnly="True"...
|
by: John Smith |
last post by:
I have this DataGrid:
<asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="SM">
<ItemTemplate>
<asp:Label id="Label2" runat="server"...
|
by: John Smith |
last post by:
I have this DataGrid:
<asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="SM">
<ItemTemplate>
<asp:Label id="Label2" runat="server"...
|
by: khalid sohail |
last post by:
hi everybody
i want to pass the window size parameter to <asp:hyperlink> attribute Navige URL Property. tell me how to pass the parameter to it.....actually i want to open the new window on the...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
| |