Hide a Column in a Datagrid

Discussion in 'ASP .Net Web Controls' started by Bob Avallone, Dec 10, 2004.

  1. Bob Avallone

    Bob Avallone Guest

    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>
     
    Bob Avallone, Dec 10, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jonnylbluejeans
    Replies:
    4
    Views:
    5,919
    Rick Spiewak
    Jul 24, 2003
  2. Thanh Nu
    Replies:
    2
    Views:
    1,001
    Thanh-Nu
    Oct 30, 2003
  3. enak

    Can't hide column in datagrid

    enak, Oct 31, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,036
    Sunil TG
    Oct 31, 2003
  4. Raterus
    Replies:
    1
    Views:
    1,653
    =?Utf-8?B?UmV6YSBOYWJp?=
    Feb 20, 2004
  5. Keithb
    Replies:
    2
    Views:
    1,204
Loading...

Share This Page