1
이것은 내 프로그램 전체 코드입니다, 유일한 문제는 내 gridview에 표시되는 소수 자릿수를 수정하려는 것입니다. 문제는 내가 asp 측면에서 열의 위치가 떨어져 던져지고 열이 중복되는 경우입니다. 나는 asp 측면에서 테이블을 다시 작성한 경우에만 문제가 발생할 것이라고 생각했다. asp side column이 데이터를 가져올 수없는 특정 열의 sql을 제거하면 문제가 발생한다.고정 열 데이터 형식 및 중복 열 문제
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>