DataGrid Dynamic HeaderText

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default DataGrid Dynamic HeaderText

    Hell

    How can I change the headerText of an AutoGenerateColumns DataGrid

    myDataGrid.DataSource=ds.Tables["Products"].DefaultView
    myDataGrid.DataBind()
    myDataGrid.Columns[0].HeaderText="MARCEL";

    in the third line I get always an exception. myDataGrid.Colums.count Returns 0!

    Thank
    Seli
    Seli Guest

  2. Similar Questions and Discussions

    1. setting headertext for a datagrid column
      Hey, can someone help me with this? I'm trying to change the headerText for a datagrid column programmatically. I'm not trying to create the...
    2. Change HeaderText of datagrid after binding
      (Type your message here) -------------------------------- From: Sangra Hi, I got a datagrid which I want to change the headertext after...
    3. How do I change the headertext of a datagrid column programmatically
      Hi, I have a datagrid to view the results from a database. I am using autogenerate because the number of columns returned from the database...
    4. change HeaderText of DataGrid in PreRender().
      I need change HeaderText of DataGrid in PreRender(). But it seems doesn't work. The code example like this: Protected Overrides Sub...
    5. How to change datagrid column HeaderText from C#
      You can do thisn DataGrid_ItemCreated Event HTH Prasad "MarkMurphy" <murphy@murphysw.com> wrote in message...
  3. #2

    Default Re: DataGrid Dynamic HeaderText

    Seli,
    You can do that in the ItemCreated event.of the DataGrid.
    Make sure that you only apply the value when the IteMType is of type header
    =>

    //I write from scratch, not Iin VS so there might be typo mistakes
    if (e.Item.ItemType==ListItemType.HeaderItem){
    e.Item[0].HeaderText="MARCEL";
    }
    Selim

    "Seli" <anonymous@discussions.microsoft.com> wrote in message
    news:0D61DB9E-6B3A-4247-9955-03315AD1AD78@microsoft.com...
    > Hello
    >
    > How can I change the headerText of an AutoGenerateColumns DataGrid?
    >
    > myDataGrid.DataSource=ds.Tables["Products"].DefaultView;
    > myDataGrid.DataBind();
    > myDataGrid.Columns[0].HeaderText="MARCEL";
    >
    > in the third line I get always an exception. myDataGrid.Colums.count
    Returns 0!!
    >
    > Thanks
    > Seli

    SB 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