J
John Blair
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;Trusted_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
ataGrid 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" />
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;Trusted_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
BackColor="#ccccff" BorderColor="black"
ShowFooter="false" CellPadding="3" CellSpacing="3" Font-Name="Verdana"
Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
EnableViewState="false" />