Hide a Column in a Datagrid

B

Bob Avallone

I hope this is the best forum for this questions

I am binding a datatable to a datagrid, but I want to hide column zero.

I got this code to work with a windows based data grid but it does not work
with a webform. Please help.

dtgResults.DataSource = mcloResults.GetDataTable()

dtgResults.DataBind()

Public Function GetDataTable() As DataTable
Try
mdtAny = mdsAny.Tables(0)

mdtAny.Columns(0).ColumnMapping = MappingType.Hidden

Return mdtAny
Catch excAny As Exception
gcloGetMessage.DisplayError(excAny)

Return Nothing
Exit Function ' bExecuteCommand
End Try

End Function

Here is the html for the datagrid


<asp:DataGrid id="dtgResults" runat="server" Width="800px" Height="149px"
BorderColor="Tan" BorderWidth="1px"
BackColor="LightGoldenrodYellow" CellPadding="2" ForeColor="Blue"
AllowPaging="True" BorderStyle="Solid">
<SelectedItemStyle ForeColor="GhostWhite"
BackColor="DarkSlateBlue"></SelectedItemStyle>
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<ItemStyle Height="20px" Width="20px"></ItemStyle>
<HeaderStyle Font-Bold="True" BorderWidth="20px" BorderStyle="Solid"
BackColor="Tan"></HeaderStyle>
<FooterStyle BackColor="Tan"></FooterStyle>
<PagerStyle VerticalAlign="Middle" HorizontalAlign="Left"
ForeColor="DarkSlateBlue" BackColor="PaleGoldenrod"></PagerStyle>
</asp:DataGrid></P>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top