2016-01-21 126 views
1

我有一個query它顯示gridview。但它與來自aspx的SR.NO沒有任何關係。按順序顯示gridview行按照desc

現在我想要的是。我想在sr.no的基礎上顯示gridview

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遞減

+0

您的數據源沒有SNo – Imad

+0

@匿名:我在代碼隱藏中綁定,它不包含'Sr.No' – BNN

+0

默認情況下,哪個訂單獲取數據?任何列? – Imad

回答

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。

+0

在哪裏寫評論?更新與完整query.please – BNN

+0

我添加爲'SELECT ROW_NUMBER()OVER(ORDER BY ab.project_id)AS sno',但** desc **部分在哪裏? – BNN