GridView, SortedAscendingCellStyle server side databinding
I try to use SortedAscendingCellStyle to assign the style of my gridView this is my ASP Code:
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" CellPadding="4" OnSorting="GridView1_Sorting" AutoGenerateColumns="false">
<SortedAscendingCellStyle CssClass="SortedAscendingCellStyle" />
<SortedAscendingHeaderStyle CssClass="SortedAscendingHeaderStyle" />
<SortedDescendingCellStyle CssClass="SortedDescendingCellStyle" />
<SortedDescendingHeaderStyle CssClass="SortedDescendingHeaderStyle " />
<Columns>
<asp:BoundField DataField="Nom" HeaderText="Nom" SortExpression="NOM">
<ItemStyle Width="150px" />
</asp:BoundField>开发者_如何学运维;
<asp:BoundField DataField="Prenom" HeaderText="Prenom">
<ItemStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="Pseudo" HeaderText="Pseudo"></asp:BoundField>
<asp:BoundField DataField="Mail" HeaderText="Mail">
<ItemStyle Width="140px" />
</asp:BoundField>
</Columns>
</asp:GridView>
there is no problem when i use DataSourceID, but when I use server side databining the SortedAscendingCellStyle Did Not work, this my code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
EmployeDAL oem = new EmployeDAL();
this.GridView1.DataSource = oem.GetAll();
GridView1.DataBind();
}
}
From my research it appears that you cannot use these nice attributes you when manually bind your GridView in the code-behind. You can find another discussion on this topic here:
http://forums.asp.net/t/1725183.aspx/1
...and also here...
http://www.aarongoldenthal.com/post/2009/04/19/Manually-Databinding-a-GridView.aspx
Good luck! I'm trying to figure out a solution to the same problem..
精彩评论