G
gane
Hi
I have a datagrid with bound columns generated in code behind with
allowsorting set to true and OnSortCommand set to a sort function. I can see
the sorted results only if i remove the autogeneratecolumns = false,
otherwise i am not getting the results.
It is not getting to the dgresults_sort function when i clicked on the
column_header link.
Any thing i am missing in my code?
code:
<tr>
<td><asp:datagrid id="dgresults" runat="server"
CssClass="GridHeaderTemplate" GridLines="None" AllowSorting="True"
CellSpacing="1" CellPadding="1"
OnItemDataBound="dgresults_ItemDataBound" OnSortCommand="dgresults_sort"
AutoGenerateColumns =False>
<AlternatingItemStyle
cssclass="GridAlternatingItemTemplate"></AlternatingItemStyle>
<ItemStyle CssClass="GridItemTemplate"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="verdana"
BorderWidth="2px" ForeColor="white" BorderStyle="None"
BackColor="Gray"></HeaderStyle>
</asp:datagrid></td>
</tr>
codebehind:
public void dgresults_sort(object sender, DataGridSortCommandEventArgs e)
{
SortField = (string)e.SortExpression;
CreateDataSource();
}
I have a datagrid with bound columns generated in code behind with
allowsorting set to true and OnSortCommand set to a sort function. I can see
the sorted results only if i remove the autogeneratecolumns = false,
otherwise i am not getting the results.
It is not getting to the dgresults_sort function when i clicked on the
column_header link.
Any thing i am missing in my code?
code:
<tr>
<td><asp:datagrid id="dgresults" runat="server"
CssClass="GridHeaderTemplate" GridLines="None" AllowSorting="True"
CellSpacing="1" CellPadding="1"
OnItemDataBound="dgresults_ItemDataBound" OnSortCommand="dgresults_sort"
AutoGenerateColumns =False>
<AlternatingItemStyle
cssclass="GridAlternatingItemTemplate"></AlternatingItemStyle>
<ItemStyle CssClass="GridItemTemplate"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="verdana"
BorderWidth="2px" ForeColor="white" BorderStyle="None"
BackColor="Gray"></HeaderStyle>
</asp:datagrid></td>
</tr>
codebehind:
public void dgresults_sort(object sender, DataGridSortCommandEventArgs e)
{
SortField = (string)e.SortExpression;
CreateDataSource();
}