2010-11-30 16 views
1

これは私のプログラムの完全なコードです。唯一の問題は、私のグリッドビューに表示される小数点以下の桁数を修正したいのです。問題は、asp側でこれを行うと、列の位置がスローされ、列が複製されるということです。私は、私はちょうど問題が働くだろうASP側でテーブルを作り直した場合、私は特定の列のSQLを削除する場合は、ASP側の列はデータを取得することはできませんでした。固定列のデータ型と重複列の問題

Imports System.Data.Sql 
    Imports System.Data.SqlClient 
    Imports System.Data 
    Partial Class _Default 
     Inherits System.Web.UI.Page 
     Public saocmd As New SqlCommand() 
     Public saoda As New SqlDataAdapter(saocmd) 

     Dim saods As New DataSet 

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
      saocmd.Connection = conn 
      conn.Open() 

      Dim ds As New DataSet 

      saocmd.CommandText = "SELECT B603SalesAsOFMASTER.SDESCR, B603SalesAsOFMASTER.DYYYY, B603SalesAsOFMASTER.AsOFSales, B603SalesAsOFMASTER.ASOFPAX, B603SalesAsOFMASTER.YESales, B603SalesAsOFMASTER.YEPAX, B603SalesAsOFMASTER.PCTofSales, B601SalesAsOF.Sales AS [Current Sales], B601SalesAsOF.PAX AS [Current PAX] FROM B603SalesAsOFMASTER INNER JOIN B601SalesAsOF ON B603SalesAsOFMASTER.SDESCR = B601SalesAsOF.SDESCR WHERE (B603SalesAsOFMASTER.DYYYY = '2008') AND (B601SalesAsOF.DYYYY = '2010')" 
      saoda.Fill(saods, "salesasoftable") 

      Dim pctofpax As New DataColumn 
      pctofpax = New DataColumn("PCTPAX1", GetType(Decimal)) 
      pctofpax.Expression = "[ASOFPAX]/[YEPAX]" 
      saods.Tables("salesasoftable").Columns.Add(pctofpax) 

      Dim avgppax As New DataColumn 
      avgppax = New DataColumn("AVG PAX", GetType(Double)) 
      avgppax.Expression = "[Current Sales]/[Current PAX]" 
      saods.Tables("salesasoftable").Columns.Add(avgppax) 

      Dim projectedye As New DataColumn 
      projectedye = New DataColumn("Projected YE Sales", GetType(Double)) 
      projectedye.Expression = "[Current Sales]/PCTofSales" 
      saods.Tables("salesasoftable").Columns.Add(projectedye) 

      Dim projectedyep As New DataColumn 
      projectedyep = New DataColumn("Projected YE PAX", GetType(Double)) 
      projectedyep.Expression = "[Current PAX]/PCTPAX1" 
      saods.Tables("salesasoftable").Columns.Add(projectedyep) 



      GridView1.DataSource = saods 

      GridView1.DataBind() 

      saoda.FillSchema(saods, SchemaType.Mapped) 

      conn.Close() 
     End Sub 
    End Class 

ASP Side 



    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head runat="server"> 
     <title></title> 
    </head> 
    <body> 
     <form id="form1" runat="server"> 
     <div> 

      <span lang="en-us">Sales As Of Analysis</span><br /> 
      <asp:GridView ID="GridView1" runat="server" BackColor="White" 
        BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
        GridLines="Vertical"> 
     <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> 
     <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> 
     <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> 
     <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> 
     <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> 
     <AlternatingRowStyle BackColor="#DCDCDC" /> 
     <Columns> 
      <asp:Boundfield DataField="SDESCR" 
          HeaderText="Regions"> 
      </asp:Boundfield> 

      <asp:Boundfield DataField="DYYYY" 
          HeaderText="DYYYY"> 
      </asp:Boundfield> 


      <asp:Boundfield DataField="asofsales" 
          HeaderText="As Of Sales" 
          DataFormatString="{0:c}"> 
      </asp:Boundfield> 
     </Columns> 
    </asp:GridView> 

     </div> 
     </form> 
    </body> 
    </html> 

答えて

4

答えは、自動生成列をオフにすることでした。

関連する問題