Link to home
Start Free TrialLog in
Avatar of codequest
codequest

asked on

Customize Gridview header

Is it possible to customize the gridview header row to the extent of putting a template field with a panel full of controls in it?  If so, how might I access that row for that purpose?
ASKER CERTIFIED SOLUTION
Avatar of spdude
spdude

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of codequest
codequest

ASKER

Thanks for input.   I'll investigate and get back to you.
spdude:  Actually, I found gridview has the same capability.   In the gridview smarttag, choose edit templates, and choose template header.   That starts it, and you can either edit there or directly in source.  

Since you got me started, if you'll respond acknowledging this post, I'll accept that as the answer.
Hi codequest

I tried your suggestion but I was not able to find header template for gridview. I don’t know how you got template header in edit templates.

But I you still wanna use grid view then I got one more trick
Make the ShowHeader="false" FOR gridview
Take a table add 2 rows in first row add the column header with panel
And in second row put the grid view


Good luck
spdude
      
      
Try

>  new asp.net website
>  new webform
>  add gridview
>  add new column > template field
>  add element to template field  (or not, didn't check)
>  then in template editing
    >  gridview tasks
    >  template editing mode
    >  display
        >  dropdown shows header template

the dropdown didn't show the header template until I added the new template column


hey codequest

thanks for showing me the exact steps

i just love this site

what to do you think of my table solution ?


dude:  ditton on the site.  Table solution is good;  I started building my rows in vb.net code behind, though, and I'm hooked!
can u paste some of your code ?
Mon pleasure.  Here's a simplified example (and note on why not perfect, yet)

http://forums.asp.net/thread/1252566.aspx

Luck!
Here's the setup in the datarowbound event for the gridview

Protected Sub XYZGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles XYZGridView.RowDataBound

        Select Case e.Row.RowType
            Case DataControlRowType.DataRow              
                'get the row
                Dim wrkRow As DataRowView = CType(e.Row.DataItem, DataRowView)
               '  find the panel, and get it's controls  

                Dim wrkPanel As Panel = e.Row.Cells(0).Controls(0).FindControl("XZYPanel")
                Dim wrkPanelControls As ControlCollection = wrkPanel.Controls

                '  instatiate the build menu class
                Dim exeControls As New MyRowControls   ' a custom class

                ' put the row fields that will be used in the data structure  
               Dim gRow As New RowStructure
                exeControls.FillRowStructure(gRow, wrkRow)

                '  build the row
                exeControls.BuildRow(gRow, wrkPanelControls)

            Case DataControlRowType.Header
                (similar stuff, though no data structure is needed because the header row is built from static info)

The BuildRow method sorts out several cases, but eventually gets to the "add control" code cited in the message above.

RowStructure is a data structure I built so I can use the intellisense in the called methods, since DataRowView can't be typed.   I'm sure it's going to cost me when I scale up to 10,000,000 users.... :o)