2012-08-24 75 views
0

存在我有下面的代碼:難道不是在目前情況下

後面的代碼:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.UI.DataVisualization.Charting; 

namespace TestApp2 
{ 
    public partial class hookload : System.Web.UI.Page 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 
      if (Request.QueryString["Rig_ID"].Equals(1)) 
       MultiView1.ActiveViewIndex = 0; 
      else if (Request.QueryString["Rig_ID"].Equals(2)) 
       MultiView1.ActiveViewIndex = 1; 
      else if (Request.QueryString["Rig_ID"].Equals(3)) 
       MultiView1.ActiveViewIndex = 2; 
      else if (Request.QueryString["Rig_ID"].Equals(4)) 
       MultiView1.ActiveViewIndex = 3; 
      else if (Request.QueryString["Rig_ID"].Equals(5)) 
       MultiView1.ActiveViewIndex = 4; 
     } 
    } 
} 

這是我的aspx文件:

<%@ Page Title="Shannons Proof of Concept Rig Dashboard" Language="C#" MasterPageFile="~/Site.master" 
    AutoEventWireup="true" CodeBehind="hookload.aspx.cs" Inherits="TestApp2._Default" %> 

<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
    Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %> 

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
    <asp:MultiView ID="MultiView1" runat="server"> 
     <asp:View ID="View1" runat="server"> 
      <asp:SqlDataSource ID="SqlDataSource27" runat="server" ConnectionString="<%$ ConnectionStrings:RigDashConnectionString1 %>" 
       SelectCommand="SELECT TOP (30) tbl_rig.name, tbl_stats.Timestamp AS Expr1, tbl_stats.HookLoad, tbl_stats.Rig_ID FROM tbl_rig INNER JOIN tbl_stats ON tbl_rig.rig_id = tbl_stats.Rig_ID WHERE (tbl_stats.Rig_ID = 2) ORDER BY Expr1 DESC"> 
      </asp:SqlDataSource> 
      <h2> 
       Rig Hook Load Stats - Previous 10 minutes</h2> 
      <p> 
       <asp:Chart ID="Chart25" runat="server" DataSourceID="SqlDataSource27" Width="900px" 
        Height="500px" Style="margin-top: 5px" Palette="EarthTones"> 
        <Series> 
         <asp:Series Name="Rig 24 Hook Load" XValueMember="Expr1" XValueType="Time" YValueMembers="HookLoad" 
          Legend="Legend" YValuesPerPoint="1" ChartType="Line"> 
         </asp:Series> 
        </Series> 
        <ChartAreas> 
         <asp:ChartArea Name="ChartArea1"> 
          <Area3DStyle Enable3D="True" LightStyle="Realistic" WallWidth="0" /> 
         </asp:ChartArea> 
        </ChartAreas> 
        <Legends> 
         <asp:Legend Name="Legend" Title="Legend"> 
         </asp:Legend> 
        </Legends> 
       </asp:Chart> 
      </p> 
     </asp:View> 
     <asp:View runat="server"> 
      <asp:SqlDataSource ID="SqlDataSource28" runat="server" ConnectionString="<%$ ConnectionStrings:RigDashConnectionString1 %>" 
       SelectCommand="SELECT TOP (30) tbl_rig.name, tbl_stats.Timestamp AS Expr1, tbl_stats.HookLoad, tbl_stats.Rig_ID FROM tbl_rig INNER JOIN tbl_stats ON tbl_rig.rig_id = tbl_stats.Rig_ID WHERE (tbl_stats.Rig_ID = 3) ORDER BY Expr1 DESC"> 
      </asp:SqlDataSource> 
      <h2> 
       Rig Hook Load Stats - Previous 10 minutes</h2> 
      <p> 
       <asp:Chart ID="Chart26" runat="server" DataSourceID="SqlDataSource28" Width="900px" 
        Height="500px" Style="margin-top: 5px" Palette="EarthTones"> 
        <Series> 
         <asp:Series Name="Rig 21 Hook Load" XValueMember="Expr1" XValueType="Time" YValueMembers="HookLoad" 
          Legend="Legend" YValuesPerPoint="1" ChartType="Line"> 
         </asp:Series> 
        </Series> 
        <ChartAreas> 
         <asp:ChartArea Name="ChartArea1"> 
          <Area3DStyle Enable3D="True" LightStyle="Realistic" WallWidth="0" /> 
         </asp:ChartArea> 
        </ChartAreas> 
        <Legends> 
         <asp:Legend Name="Legend" Title="Legend"> 
         </asp:Legend> 
        </Legends> 
       </asp:Chart> 
      </p> 
     </asp:View> 
     <asp:View runat="server"> 
      <asp:SqlDataSource ID="SqlDataSource29" runat="server" ConnectionString="<%$ ConnectionStrings:RigDashConnectionString1 %>" 
       SelectCommand="SELECT TOP (30) tbl_rig.name, tbl_stats.Timestamp AS Expr1, tbl_stats.HookLoad, tbl_stats.Rig_ID FROM tbl_rig INNER JOIN tbl_stats ON tbl_rig.rig_id = tbl_stats.Rig_ID WHERE (tbl_stats.Rig_ID = 5) ORDER BY Expr1 DESC"> 
      </asp:SqlDataSource> 
      <h2> 
       Rig Hook Load Stats - Previous 10 minutes</h2> 
      <p> 
       <asp:Chart ID="Chart27" runat="server" DataSourceID="SqlDataSource29" Width="900px" 
        Height="500px" Style="margin-top: 5px" Palette="EarthTones"> 
        <Series> 
         <asp:Series Name="Rig 22 Hook Load" XValueMember="Expr1" XValueType="Time" YValueMembers="HookLoad" 
          Legend="Legend" YValuesPerPoint="1" ChartType="Line"> 
         </asp:Series> 
        </Series> 
        <ChartAreas> 
         <asp:ChartArea Name="ChartArea1"> 
          <Area3DStyle Enable3D="True" LightStyle="Realistic" WallWidth="0" /> 
         </asp:ChartArea> 
        </ChartAreas> 
        <Legends> 
         <asp:Legend Name="Legend" Title="Legend"> 
         </asp:Legend> 
        </Legends> 
       </asp:Chart> 
      </p> 
     </asp:View> 
    </asp:MultiView> 
    <p> 
     <a href="..\default.aspx">< Go Back</a> 
    </p> 
</asp:Content> 

現在我的問題是,當我試着運行這個,我得到'The name'MultiView1'在當前上下文中不存在'的消息。我真的不明白爲什麼我會得到這個錯誤,但我也是一個小菜鳥,所以這並不奇怪。 :)基本上,我在第一頁上有一個asp:gridview表,我試圖傳遞參數,然後由這個頁面處理,所以當有人點擊鏈接〜\ charts \ hookload.aspx?Rig_ID = 2時,它會處理MultiView Index 1,因此它顯示了SQL查詢描述的相關數據圖表。

這是迄今爲止我發現的唯一途徑,因此如果其他人有更好的主意,請相信我,我都是耳朵。我一直在努力尋找答案,主要是因爲我不知道要搜索什麼關鍵字。任何幫助,將不勝感激。

回答

1

繼承屬性。

糾正你的繼承如下:當您更改類的名稱,卻忘了糾正在aspx文件

<%@ Inherits="TestApp2.hookload" Page Title="Shannons Proof of Concept Rig Dashboard" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="hookload.aspx.cs" %> 

發生的。

+0

就是這樣,謝謝! Aravind,你也是。 – Trido

1

<%@ Page Title="Shannons Proof of Concept Rig Dashboard" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="hookload.aspx.cs" Inherits="TestApp2._Default" %>

你的頁面繼承了錯誤繼承=「TestApp2._Default」你的頁面必須引用您的支持類的名稱

相關問題