由SR.NO desc按顺序显示gridview行

时间:2016-01-21 10:45:33

标签: asp.net oracle gridview

我有query,显示gridview。但它与来自aspx的 SR.NO 无关。

现在我想要的是。我希望在gridview

的基础上显示sr.no
  

desc order。

查询如下:

OracleCommand cmd = new OracleCommand(
    "SELECT pn.project_id AS project_id, pn.property_name, pn.building, pn.building_id AS building_id, " +
    "cd.flat_id AS flat_id, ab.flat_status, ab.COMMENTS, to_char(ab.CREATION_DATE, 'dd/MM/yyyy') AS CREATION_DATE " +
    "FROM xxcus.xxacl_pn_projbuild_v pn INNER JOIN xxacl_pn_flat_status_his ab ON pn.project_id = ab.project_id " +
    "AND pn.building_id = ab.building_id INNER JOIN xxacl_pn_flat_det_v cd " +
    "ON cd.flat_id = ab.flat_id where ab.delete_flag = 'N' Order by pn.property_name", ObjPriCon);

和gridview aspx是: -

<cc1:Grid ID="GrdBookingStatus" runat="server" FolderStyle="../../Styles/Grid/style_12"
    AutoGenerateColumns="false" AllowColumnResizing="true" Width="90%" ShowFooter="false"
    ShowHeader="true">
    <Columns>
        <cc1:Column ID="Column1" DataField="" ReadOnly="true" HeaderText="Sr.No" Width="5%"
            runat="server" Wrap="true">
            <TemplateSettings TemplateId="tplNumbering" />
        </cc1:Column>
        <cc1:Column ID="Column2" DataField="PROPERTY_NAME" HeaderText="Project Name" runat="server"
            Width="16%" Wrap="true">
        </cc1:Column>
        <cc1:Column ID="Column3" DataField="BUILDING" HeaderText="Building Name" runat="server"
            Width="13%" Wrap="true">
        </cc1:Column>
        <cc1:Column ID="Column4" DataField="FLAT_ID" HeaderText="Unit No" runat="server"
            Width="5%" Wrap="true">
        </cc1:Column>
        <cc1:Column ID="Column5" DataField="FLAT_STATUS" HeaderText="Unit Status" runat="server"
            Width="15%" Wrap="true">
        </cc1:Column>
        <cc1:Column ID="Column7" DataField="CREATION_DATE" HeaderText="Date" runat="server"
            Width="10%" Wrap="true">
        </cc1:Column>
        <cc1:Column ID="Column6" DataField="COMMENTS" HeaderText="Comments" runat="server"
            Width="26%" Wrap="true">
        </cc1:Column>
    </Columns>
    <Templates>
        <cc1:GridTemplate runat="server" ID="tplNumbering">
            <Template>
                <b>
                    <%# (Container.RecordIndex + 1) %></b>
            </Template>
        </cc1:GridTemplate>
    </Templates>
</cc1:Grid>

如何按SR.NO desc

进行排序

1 个答案:

答案 0 :(得分:0)

您可以使用row_number。只需选择其他列作为SNo

OracleCommand cmd = new OracleCommand(
    "SELECT row_number() OVER (ORDER BY a.full_name) AS Sno, pn.project_id AS project_id, pn.property_name, pn.building, pn.building_id AS building_id, " +
    "cd.flat_id AS flat_id, ab.flat_status, ab.COMMENTS, to_char(ab.CREATION_DATE, 'dd/MM/yyyy') AS CREATION_DATE " +
    "FROM xxcus.xxacl_pn_projbuild_v pn INNER JOIN xxacl_pn_flat_status_his ab ON pn.project_id = ab.project_id " +
    "AND pn.building_id = ab.building_id INNER JOIN xxacl_pn_flat_det_v cd " +
    "ON cd.flat_id = ab.flat_id where ab.delete_flag = 'N' Order by pn.property_name", ObjPriCon);

并更新您的gridview列的DataField。