Gridview Sorting does not work after dynamically changing the Header text


P

pargat.singh

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;
}
}
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top