开发者

how to get events in second header row in custom gridview

开发者 https://www.devze.com 2023-03-07 04:17 出处:网络
I need to add a secondary (header) row to my ASP.NET GridView (which is already customized so I can access any part of the event lifecycle).

I need to add a secondary (header) row to my ASP.NET GridView (which is already customized so I can access any part of the event lifecycle).

It's additional data that I want aligned with some of the columns.

It should look like this

Period    |  May  |  June | July | Aug      -- Header
Basevalue | 3000  | 1500  | 1200 | 4000     -- EXTERNAL DATA
---------------------------------------
Item 1    |  100  |  200  |  300 |  400    
Item 2    |  100  |  200  |  300 |  400      

I managed to add a row with below code, but I am unable to create any kind of custom event where I could gain access and write my custom data into that cell. I tried the following, but during any event I could find (like OnRowCreated or PrepareControlHierarchy), it'开发者_Python百科s either too late (after databinding) or the inner table is not initalized.

int rowIndex = 0;

GridViewRow secondHeaderRow = new GridViewRow(rowIndex, -1, DataControlRowType.Header, DataControlRowState.Normal);
secondHeaderRow.TableSection = TableRowSection.TableHeader;

foreach (DataControlField col in this.Columns)
            {
                TableHeaderCell cell = new TableHeaderCell();
                cell.DataBinding += new EventHandler(OnHeaderCellDatabinding);
                secondHeaderRow.Cells.Add(cell);
            }

 InnerTable.Rows.AddAt(rowIndex, secondHeaderRow);

How can I hook up to the GridView lifecycle to write in the header row?


hey niles, we can use the caption to some HTML tags and start building the extra headers

please refer this link for your problem

CLICK HERE

hope it will help you


Try this. Merging columns in GridView/DataGrid header

0

精彩评论

暂无评论...
验证码 换一张
取 消