Trying to hide a datatable column from my datagrid... please help

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Trying to hide a datatable column from my datagrid... please help

    I've read everywhere to use the following:

    objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden

    objDS.AcceptChanges()

    dgNotes.DataSource = objDS.Tables("Results")

    dgNotes.DataBind()



    But, the column still shows? Can anyone shed some light on this?


    jonnylbluejeans Guest

  2. Similar Questions and Discussions

    1. Bound datatable + unbound column in datagrid
      Is is possible to create an ASP.NET datagrid that mixes bound data pulled from a database table with an unbound column created by the program? I...
    2. How to add New Column to existing DataTable in specific position.
      I want to add new DataColumn to existing DataTable object as first column shown in the datagrid. (like DataColumn dc = new DataColumn("Target");...
    3. Binding Two DataTable Columns to One DataGrid Column
      I have a DataTable that I am binding to a DataGrid. I need to take two columns in the DataTable, and bind them to one row in the DataGrid (for...
    4. How can I hide a column in my Datagrid
      I have a datagrid I am populating programmatically, creating the rows and columns. I need to hide one column. How can I do this? I have seen...
    5. DataTable - replace values in column
      How would I replace all the values in a column in a DataTable with another value (which is the same for every row)?
  3. #2

    Default Re: Trying to hide a datatable column from my datagrid... please help

    jonny,

    I haven't seen any code like you're using before.

    I hide columns by simply setting the column's visibility property.

    Here's how I do it when I'm creating the datagrid myself:

    <asp:boundcolumn visible="False" datafield="pk_EntryId"></asp:boundcolumn>

    And here's how I set it from the codebehind:

    DataGrid1.Columns(0).Visible = False

    I hope this helps.
    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "jonnylbluejeans" <john.lepone@arch.com> wrote in message
    news:uEa8ITVUDHA.1992@TK2MSFTNGP12.phx.gbl...
    > I've read everywhere to use the following:
    >
    > objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden
    >
    > objDS.AcceptChanges()
    >
    > dgNotes.DataSource = objDS.Tables("Results")
    >
    > dgNotes.DataBind()
    >
    >
    >
    > But, the column still shows? Can anyone shed some light on this?
    >
    >

    S. Justin Gengo Guest

  4. #3

    Default Re: Trying to hide a datatable column from my datagrid... pleasehelp

    Perhaps your problem lies within the implementation of the DataGrid -
    have you tried using bound columns instead of just databinding to the
    default Grid?

    -Christopher
    [url]http://weblogs.asp.net/CFrazier[/url]

    jonnylbluejeans wrote:
    > I've read everywhere to use the following:
    >
    Christopher Frazier Guest

  5. #4

    Default Re: Trying to hide a datatable column from my datagrid... please help

    Use the ItemCreated Event to
    Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemCreated

    Select Case e.Item.ItemType

    Case ListItemType.Header,ListItemType.AlternativeItem,L istItemType....

    e.Item.Cells(1).Visible = False


    End Sub


    "jonnylbluejeans" <john.lepone@arch.com> wrote in message
    news:uEa8ITVUDHA.1992@TK2MSFTNGP12.phx.gbl...
    > I've read everywhere to use the following:
    >
    > objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden
    >
    > objDS.AcceptChanges()
    >
    > dgNotes.DataSource = objDS.Tables("Results")
    >
    > dgNotes.DataBind()
    >
    >
    >
    > But, the column still shows? Can anyone shed some light on this?
    >
    >

    Jerry Guest

  6. #5

    Default Re: Trying to hide a datatable column from my datagrid... please help

    Thanks for this one! It solved a different problem for me:

    If I set a column's Visible property to False (unchecking in the columns
    property page), the value read from it is empty. Using this technique makes
    the column invisible without causing that side-effect.

    Frankly, in the case of my problem, I think it's a bug!! But, whatever it
    takes....

    "Jerry" <JGAO2183@rogers.com> wrote in message
    news:jMITa.20466$vz%.12010@news01.bloor.is.net.cab le.rogers.com...
    > Use the ItemCreated Event to
    > Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    > DataGrid1.ItemCreated
    >
    > Select Case e.Item.ItemType
    >
    > Case ListItemType.Header,ListItemType.AlternativeItem,L istItemType....
    >
    > e.Item.Cells(1).Visible = False
    >
    >
    > End Sub
    >
    >
    > "jonnylbluejeans" <john.lepone@arch.com> wrote in message
    > news:uEa8ITVUDHA.1992@TK2MSFTNGP12.phx.gbl...
    > > I've read everywhere to use the following:
    > >
    > > objDS.Tables("Results").Columns(0).ColumnMapping = MappingType.Hidden
    > >
    > > objDS.AcceptChanges()
    > >
    > > dgNotes.DataSource = objDS.Tables("Results")
    > >
    > > dgNotes.DataBind()
    > >
    > >
    > >
    > > But, the column still shows? Can anyone shed some light on this?
    > >
    > >
    >
    >

    Rick Spiewak Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139