Grdiview Sorting problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pargat.singh@gmail.com

    #1

    Grdiview Sorting problem

    Hi:

    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="Vert ical"
    ShowFooter="Tru e" CssClass="gridv iew"
    AlternatingRowS tyle-CssClass="even" Width="620px"
    runat="server" AutoGenerateCol umns="False"
    DataSourceID="O bjectDataSource 2" AllowSorting="t rue"
    OnDataBound="Gr idView1_DataBou nd"
    OnRowDataBound= "GridView1_RowD ataBound"
    OnRowCreated="G ridView1_RowCre ated"
    EnableViewState ="true">
    <Columns>
    <asp:BoundFie ld HtmlEncode="Fal se" HeaderStyle-
    VerticalAlign=" Top" DataFormatStrin g="{0:C4}"
    DataField="GRAN T_PRICE"
    SortExpression= "GRANT_PRIC E" ItemStyle-HorizontalAlign ="right" />
    <asp:BoundFie ld DataField="GRAN T_DATE"
    HeaderStyle-HorizontalAlign ="Right" HeaderStyle-VerticalAlign=" Top"
    ItemStyle-Wrap="false"
    SortExpression= "GRANT_DATE " ItemStyle-HorizontalAlign ="right" />
    <asp:BoundFie ld DataField="PLAN _ID"
    HeaderStyle-VerticalAlign=" Top" SortExpression= "PLAN_ID" />
    <asp:BoundFie ld DataField="AGGR EMENT"
    HeaderStyle-VerticalAlign=" Top" SortExpression= "AGGREMENT" />
    <asp:BoundFie ld DataField="BALA NCE_OPTIONS"
    HeaderStyle-VerticalAlign=" Top" SortExpression= "BALANCE_OPTION S"
    ItemStyle-HorizontalAlign ="right" />
    </Columns>
    <AlternatingRow Style />
    </asp:GridView>

    <asp:ObjectData Source ID="ObjectDataS ource2"
    runat="server" SelectMethod="G etDetail"
    TypeName="cBMOS OP">
    <SelectParamete rs>
    <asp:ControlPar ameter ControlID="clie ntIDH"
    Name="clientID" PropertyName="V alue"
    Type="String" />
    <asp:ControlPar ameter ControlID="base IDH"
    Name="baseID" PropertyName="V alue" Type="String" />
    </SelectParameter s>
    </asp:ObjectDataS ource>


    protected void GridView1_RowCr eated( object sender,
    GridViewRowEven tArgs e )
    {
    if ( e.Row.RowType == DataControlRowT ype.Header )
    {
    e.Row.Cells[0].Text = lblGrantPrice.V alue;
    e.Row.Cells[0].ColumnSpan = 2;
    e.Row.Cells[0].HorizontalAlig n = HorizontalAlign .Right;
    e.Row.Cells[1].Text = lblGrantDate.Va lue;
    e.Row.Cells[1].HorizontalAlig n = HorizontalAlign .Left;
    e.Row.Cells[2].Text = lblPlanID.Value ;
    e.Row.Cells[2].HorizontalAlig n = HorizontalAlign .Left;
    e.Row.Cells[3].Text = lblAggrementRec eived.Value;
    e.Row.Cells[3].HorizontalAlig n = HorizontalAlign .Left;
    e.Row.Cells[4].Text = lblAvailableSha res.Value;
    e.Row.Cells[4].HorizontalAlig n = HorizontalAlign .Right;
    e.Row.Cells[5].Text = lblOptionToExer cise.Value;
    e.Row.Cells[5].HorizontalAlig n = HorizontalAlign .Right;
    }
    }

Working...