我在做毕业设计可是vs2005进行调试后显示。 CS0117: “DaGangList”并不包含“DataList1”的定义。线上等,急!急!急!

qq_33677278 2016-05-11 03:56:06


行 59: }
行 60:
行 61: this.DataList1.DataSource = objPds;
行 62: this.DataList1.DataBind();
行 63: con.Close();






aspx页面代码:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="DaGangList.aspx.cs" Inherits="DaGangList" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tr>
<td align="left" bgcolor="#fbfbfb" class="middle_border_1 margin_middle1" style="width: 661px; height: 134px;">

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="课程名称"
DataSourceID="SqlDataSource1">

<Columns>
<asp:BoundField DataField="课程名称" HeaderText="课程名称" ReadOnly="True" SortExpression="课程名称" />
<asp:BoundField DataField="任课老师" HeaderText="任课老师" SortExpression="任课老师" />
<asp:BoundField DataField="上课时间" HeaderText="上课时间" SortExpression="上课时间" />
<asp:BoundField DataField="学费(元)" HeaderText="学费(元)" SortExpression="column1" />
<asp:BoundField DataField="操作" HeaderText="操作" SortExpression="操作" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:JavaCourseWebConnectionString %>"
SelectCommand="SELECT [课程名称], [任课老师], [上课时间], [学费(元)] AS column1, [操作] FROM [course]">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td align="center" bgcolor="#fbfbfb" class="middle_border_1 margin_middle1" style="width: 661px;
height: 38px">
共【<asp:Label ID="lblSumPage" runat="server"></asp:Label>】页      
当前第【<asp:Label ID="lblCurrentPage" runat="server"></asp:Label>】页 
<asp:HyperLink ID="hyfirst" runat="server">首页</asp:HyperLink>
     <asp:HyperLink ID="lnkPrev" runat="server">上一页</asp:HyperLink>
           
<asp:HyperLink ID="lnkNext" runat="server">下一页</asp:HyperLink>
        
<asp:HyperLink ID="hylastpage" runat="server">尾页</asp:HyperLink>
</td>
</tr>
</table>
</asp:Content>

cs页面的代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class DaGangList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvbind();
}
}
private void gvbind()
{
string sql = "select * from News where TypeName='教学大纲' order by id desc";
SqlConnection con = new SqlConnection(SqlHelper.connstring);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
sda.Fill(ds);


PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[0].DefaultView;

objPds.AllowPaging = true;
objPds.PageSize = 39;

int CurPage;
if (Request.QueryString["Page"] != null)
CurPage = Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage = 1;

objPds.CurrentPageIndex = CurPage - 1;
lblCurrentPage.Text = CurPage.ToString();
lblSumPage.Text = objPds.PageCount.ToString();

if (!objPds.IsFirstPage)
{
this.hyfirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + 1;
lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
}

if (!objPds.IsLastPage)
{
hylastpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + objPds.PageCount;

lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
}

this.DataList1.DataSource = objPds;
this.DataList1.DataBind();
con.Close();
}
protected string CutChar(string strChar, int intLength)
{
//取得自定义长度的字符串
if (strChar.Length > intLength)
{ return strChar.Substring(0, intLength); }
else
{ return strChar; }

}
}
...全文
110 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧