Results 1 to 4 of 4

Thread: Change datagrid header from code behind

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Change datagrid header from code behind

    I have a dtagrid called datagrid1. When I have my code behind process run I want to be able to change the header text of the datagrid from there.

    Can someone give me an example of some code that will do this from the VB code behind?

    I'm using VS .Net 2003.

    Thanks
    David Wilhelm

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Change datagrid header from code behind

    In the ItemDataBound event, first check whether e.ItemType = Header.

    If it is a header, then you can simply access e.Item[0] (or any numeric value) and change its text property or innerhtml or innertext property.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612

    Re: Change datagrid header from code behind

    Quoting myself...
    Can someone give me an example of some code that will do this from the VB code behind?
    David Wilhelm

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Change datagrid header from code behind

    If e.Item.ItemType = ListItemType.Header Then
    e.Item.Cells(0).Text = "SOMETHING"
    End If

Posting Permissions

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



Click Here to Expand Forum to Full Width