问题是这样的:
今天从网上弄了一网站代码,IIS运行一切正常。于是想自己做一下。
打开VS编写完了第一部分。发现运行后存在问题:
当我的HTML中放置DataGrid的代码后在设计窗体内可以正常显示DataGrid的外形。运行调试一切OK。
但是显示出的网页却无法从数据库中提取文件,DataGrid处于空白状态。
于是我打开原文件,我将原<html>……</html>的所有内容覆盖了我自己做的。但是显示内容也是如此。
两个default.aspx的区别只有第一行黄色的字不同。
我编写的:(由系统自己生成)(我的命名空间:Newstest 类名MyCodeBehind)
<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false" Inherits="Newstest.MyCodeBehind" %>
原文件:(原来的文件)
<%@ Page Inherits="www.MyCodeBehind" Src="www.cs" %> 以下是HTML中DataGrid的段落:<ASP:DataGrid id="MyList" runat="server" Width="400" GridLines="None" ShowFooter="false" CellPadding="2" CellSpacing="1" Font-Name="宋体" Font-Size="8pt" EnableViewState="false" AutoGenerateColumns="false">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink Text='<%# FormatString(DataBinder.Eval(Container.DataItem,"biaoti").ToString())%>' NavigateUrl='<%# "javascript:newwin(\"shownews.aspx?id="+DataBinder.Eval(Container.DataItem,"id").ToString()+"\");" %>' runat="server"/>
<%# DataBinder.Eval(Container.DataItem, "shijian","{0:d}")%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</ASP:DataGrid>
现在不理解为什么会出现这种情况 !
数据库我采用ACCESS,数据库我是COPY原来的文件的。而且我把其他的文件(除了我建立的那个)COPY到我建立的文件目录下。其他文件都运行正常。
今天从网上弄了一网站代码,IIS运行一切正常。于是想自己做一下。
打开VS编写完了第一部分。发现运行后存在问题:
当我的HTML中放置DataGrid的代码后在设计窗体内可以正常显示DataGrid的外形。运行调试一切OK。
但是显示出的网页却无法从数据库中提取文件,DataGrid处于空白状态。
于是我打开原文件,我将原<html>……</html>的所有内容覆盖了我自己做的。但是显示内容也是如此。
两个default.aspx的区别只有第一行黄色的字不同。
我编写的:(由系统自己生成)(我的命名空间:Newstest 类名MyCodeBehind)
<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="false" Inherits="Newstest.MyCodeBehind" %>
原文件:(原来的文件)
<%@ Page Inherits="www.MyCodeBehind" Src="www.cs" %> 以下是HTML中DataGrid的段落:<ASP:DataGrid id="MyList" runat="server" Width="400" GridLines="None" ShowFooter="false" CellPadding="2" CellSpacing="1" Font-Name="宋体" Font-Size="8pt" EnableViewState="false" AutoGenerateColumns="false">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink Text='<%# FormatString(DataBinder.Eval(Container.DataItem,"biaoti").ToString())%>' NavigateUrl='<%# "javascript:newwin(\"shownews.aspx?id="+DataBinder.Eval(Container.DataItem,"id").ToString()+"\");" %>' runat="server"/>
<%# DataBinder.Eval(Container.DataItem, "shijian","{0:d}")%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</ASP:DataGrid>
现在不理解为什么会出现这种情况 !
数据库我采用ACCESS,数据库我是COPY原来的文件的。而且我把其他的文件(除了我建立的那个)COPY到我建立的文件目录下。其他文件都运行正常。
解决方案 »
- AspxTreeList和AspxGridView控件 数据绑定
- RadioButtonList的SelectedIndexChanged事件怎么触发
- 怎么让域和空间绑定啊
- 请问调用基类构造函数在EA的类图中怎么表示?
- 用户自定义控件的位置和大小?
- 为什么我的asp.net程序,无法调用asp登陆页面设定的cookies值?是不是当跨语言、跨域时都无效?可有没有办法解决呢? 要不然程序没法运
- 刚转过.NET来,发现个重大问题
- .net創建WEB項目
- 网页上突然显示不出SQL数据库里的数据了???????????????
- 关于.net前台页面显示问题!!!不够再加200分!!!
- 这个api在c#中怎么声明和调用??
- 求救:为何出错? string argName = ((Button)sender).CommandName.ToString();
using System.Data;
using System.Data.OleDb;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls; namespace Newstest
{
/// <summary>
/// MyCodeBehind 的摘要说明。
/// </summary>
public class MyCodeBehind : Page {
protected System.Web.UI.WebControls.DataGrid MyList;
protected System.Web.UI.WebControls.DataGrid MyList1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{ OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Server.MapPath("new.mdb"));
OleDbDataAdapter myCommand = new OleDbDataAdapter("select top 12 aa.* FROM aa WHERE typeid=1 order by shijian desc", myConnection);
OleDbDataAdapter myCommand1 = new OleDbDataAdapter("select top 12 aa.* FROM aa WHERE typeid=2 order by shijian desc", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "aa");
myCommand1.Fill(ds, "bb"); MyList.DataSource = ds.Tables["aa"].DefaultView;
MyList1.DataSource = ds.Tables["bb"].DefaultView;
MyList.DataBind();
MyList1.DataBind();
}// 在此处放置用户代码以初始化页面
}
protected string FormatString(string str)
{
str=str.Replace(""," ");
str=str.Replace("<","<");
str=str.Replace(">",">");
str=str.Replace('\n'.ToString(),"<br>");
return str;
} }
}
MyList1.DataBind();
http://chs.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datalist/doc_datalist.aspx