Sort Expression multi header in gridview

ashcts

New Member
I have 2 headers in my gridview. I am inserting 2nd header in code behind on \[code\]RowCreated\[/code\] event which will be insert above \[code\]<asp:BoundField>\[/code\] row. I have added \[code\]SortExpression\[/code\] property to each \[code\]BoundField\[/code\]. When I run the application \[code\]SorExpression\[/code\] hyperlink is creating on each \[code\]BoundField\[/code\] not on inserted header (It is logically correct). But I want sortexpression on inserted header row. How can I do that?below I am explaining steps that I didASPX\[code\]<asp:GridView ID="gvInitiavtives" runat="server" Width="100%" CssClass="Grid" RowStyle-Width="30px" AutoGenerateColumns="false" HeaderStyle-CssClass="GridHeader" RowStyle-CssClass="GridItem" AlternatingRowStyle-CssClass="GridAltItem" DataKeyNames="InitiativeIdx" > <Columns> <asp:BoundField DataField="BusinessUnit" HeaderText="" HeaderStyle-Wrap="false" HeaderStyle-HorizontalAlign="NotSet" SortExpression='BusinessUnit' /> <asp:BoundField DataField="IFunction" HeaderText="" HeaderStyle-Wrap="false" HeaderStyle-HorizontalAlign="NotSet" SortExpression='IFunction'/> <asp:BoundField DataField="SubFunction" HeaderText="" HeaderStyle-Wrap="false" HeaderStyle-HorizontalAlign="NotSet" SortExpression='SubFunction' /> .....\[/code\]Code Behind\[code\] Private Sub gvInitiavtives_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvInitiavtives.RowCreated If e.Row.RowType = DataControlRowType.Header Then Dim HeaderGrid As GridView = DirectCast(sender, GridView) Dim HeaderGridRow As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert) Dim HeaderCell As New TableHeaderCell() HeaderCell.Text = "BU" HeaderGridRow.Cells.Add(HeaderCell) HeaderCell = New TableHeaderCell() HeaderCell.Text = "Function" HeaderGridRow.Cells.Add(HeaderCell) HeaderCell = New TableHeaderCell() HeaderCell.Text = "Sub - Function" HeaderGridRow.Cells.Add(HeaderCell) .... .... gvInitiavtives.Controls(0).Controls.AddAt(0, HeaderGridRow) End IfEnd Sub\[/code\]Browser
JF2l3.png
HTML\[code\] <table class="Grid" cellspacing="0" rules="all" border="1" id="Body_gvInitiavtives" style="width:100%;border-collapse:collapse;"> <tr class="GridHeader"> <th>BU</th><th>Function</th><th>Sub - Function</th><th>Initiative Name</th><th>Location</th><th>Cost Center</th><th colspan="2">Estimated Cost Savings</th><th colspan="2">Estimated Personnel Savings</th> </tr><tr class="GridHeader"> <th scope="col" style="white-space:nowrap;"><a href="javascript:__doPostBack('ctl00$Body$gvInitiavtives','Sort$BusinessUnit')"></a></th><th scope="col" style="white-space:nowrap;"><a href="javascript:__doPostBack('ctl00$Body$gvInitiavtives','Sort$IFunction')"></a></th><th scope="col" style="white-space:nowrap;"><a href="javascript:__doPostBack('ctl00$Body$gvInitiavtives','Sort$SubFunction')"></a></th><th scope="col">&nbsp;</th><th scope="col" style="white-space:nowrap;">&nbsp;</th><th scope="col" style="white-space:nowrap;">&nbsp;</th><th scope="col" style="white-space:nowrap;">Low</th><th scope="col" style="white-space:nowrap;">High</th><th scope="col" style="white-space:nowrap;">Low</th><th scope="col" style="white-space:nowrap;">High</th> </tr> <tr class="GridItem" style="width:30px;"> <td>UNKNOWN</td><td>UNKNOWN</td><td>UNKNOWN</td><td>\[/code\]Help will be appreciated.
 
Back
Top