469,962 Members | 2,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,962 developers. It's quick & easy.

Gridview sorting problem


I am using a grid and having a problem with sorting. Below are my
code and change the header name at run time as below based on
language.If i don't change the header name it work. Can someone please
help me so that i can enable the sorting and change the header as
well. Thanks, in advance.
<asp:GridView ID="GridView1" CellPadding="5"
EmptyDataText="No Data Found" GridLines="Vertical"
ShowFooter="True" CssClass="gridview"
AlternatingRowStyle-CssClass="even" Width="620px"
runat="server" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource2" AllowSorting="true"
<asp:BoundField HtmlEncode="False" HeaderStyle-
VerticalAlign="Top" DataFormatString="{0:C4}"
SortExpression="GRANT_PRICE" ItemStyle-HorizontalAlign="right" />
<asp:BoundField DataField="GRANT_DATE"
HeaderStyle-HorizontalAlign="Right" HeaderStyle-VerticalAlign="Top"
SortExpression="GRANT_DATE" ItemStyle-HorizontalAlign="right" />
<asp:BoundField DataField="PLAN_ID"
HeaderStyle-VerticalAlign="Top" SortExpression="PLAN_ID" />
<asp:BoundField DataField="AGGREMENT"
HeaderStyle-VerticalAlign="Top" SortExpression="AGGREMENT" />
<asp:BoundField DataField="BALANCE_OPTIONS"
HeaderStyle-VerticalAlign="Top" SortExpression="BALANCE_OPTIONS"
ItemStyle-HorizontalAlign="right" />
<AlternatingRowStyle />

<asp:ObjectDataSource ID="ObjectDataSource2"
runat="server" SelectMethod="GetDetail"
<asp:ControlParameter ControlID="clientIDH"
Name="clientID" PropertyName="Value"
Type="String" />
<asp:ControlParameter ControlID="baseIDH"
Name="baseID" PropertyName="Value" Type="String" />
protected void GridView1_RowCreated( object sender,
GridViewRowEventArgs e )
if ( e.Row.RowType == DataControlRowType.Header )
e.Row.Cells[0].Text = lblGrantPrice.Value;
e.Row.Cells[0].ColumnSpan = 2;
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Right;
e.Row.Cells[1].Text = lblGrantDate.Value;
e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Left;
e.Row.Cells[2].Text = lblPlanID.Value;
e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Left;
e.Row.Cells[3].Text = lblAggrementReceived.Value;
e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Left;
e.Row.Cells[4].Text = lblAvailableShares.Value;
e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Right;
e.Row.Cells[5].Text = lblOptionToExercise.Value;
e.Row.Cells[5].HorizontalAlign = HorizontalAlign.Right;

Apr 25 '07 #1
0 1305

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by yefei | last post: by
4 posts views Thread by samb | last post: by
4 posts views Thread by kurt sune | last post: by
reply views Thread by jobo | last post: by
4 posts views Thread by =?Utf-8?B?R2VyaGFyZA==?= | last post: by
2 posts views Thread by mahesh123 | last post: by
reply views Thread by Sobin Thomas | last post: by
1 post views Thread by Sobin Thomas | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.