469,927 Members | 1,785 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Gridview Sorting does not work after dynamically changing the Header text

Hi Everyone:

I have a gridview control with AllowSorting="True" and work ok.
But my page will be used by different user from different region so i
need to change the HeaderText based on language like english or french
etc.When i updat ethe header on GridView1_RowCreated sorting does not
work anymore. Below are my code. Is this because of BoundField. Can
someone please help me with this issue. Thanks in advance.

<asp:GridView ID="GridView1" AutoGenerateColumns="false"
runat="server" AllowSorting="True"
DataSourceID="ObjectDataSource1"
OnRowCreated="GridView1_RowCreated">
<Columns>
<asp:BoundField HtmlEncode="False" HeaderStyle-
VerticalAlign="Top" DataFormatString="{0:C4}"
DataField="GRANT_PRICE" HeaderText="GRANT
PRICE" HeaderStyle-ForeColor="white" SortExpression="GRANT_PRICE"
ItemStyle-HorizontalAlign="right" />
<asp:BoundField DataField="GRANT_DATE"
HeaderText="GRANT DATE" HeaderStyle-HorizontalAlign="Right"
HeaderStyle-ForeColor="white"
HeaderStyle-VerticalAlign="Top" ItemStyle-
Wrap="false" SortExpression="GRANT_DATE"
ItemStyle-HorizontalAlign="right" />
<asp:BoundField DataField="PLAN_ID"
HeaderText="PLAN_ID" HeaderStyle-VerticalAlign="Top" HeaderStyle-
ForeColor="white"
SortExpression="PLAN_ID" />
<asp:BoundField DataField="AGGREMENT"
HeaderText="AGGREMENT Received" HeaderStyle-VerticalAlign="Top"
HeaderStyle-ForeColor="white"
SortExpression="AGGREMENT" />
<asp:BoundField DataField="BALANCE_OPTIONS"
HeaderText="BALANCE OPTIONS" HeaderStyle-VerticalAlign="Top"
HeaderStyle-ForeColor="white"
SortExpression="BALANCE_OPTIONS" ItemStyle-
HorizontalAlign="right" / </Columns>
</asp:GridView>

<asp:ObjectDataSource ID="ObjectDataSource1"
runat="server" SelectMethod="GetDetail"
TypeName="cBMOSOP">
<SelectParameters>
<asp:Parameter DefaultValue="9999" Name="clientID"
Type="String" />
<asp:Parameter DefaultValue="1234567"
Name="baseID" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

protected void GridView1_RowCreated( object sender,
GridViewRowEventArgs e )
{
if ( e.Row.RowType == DataControlRowType.Header )
{
e.Row.Cells[0].Text = "GrantPrice1";
e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Left;
e.Row.Cells[1].Text = "GrantDate1";
e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Left;
e.Row.Cells[2].Text = "PlanID1";
e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Left;
e.Row.Cells[3].Text = "AggrementReceived1";
e.Row.Cells[3].HorizontalAlign = HorizontalAlign.Left;
e.Row.Cells[4].Text = "AvailableShares1";
e.Row.Cells[4].HorizontalAlign = HorizontalAlign.Right;
}
}

Apr 24 '07 #1
0 1768

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by pmud | last post: by
1 post views Thread by tfsmag | last post: by
5 posts views Thread by yefei | last post: by
1 post views Thread by Evan M. | last post: by
reply views Thread by pargat.singh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.