<#list datalist1 as data>是什么标签
2个回答
展开全部
这只是一个标记
string temlpatestream=读到的模版流;
temlpatestream.replace("<#list datalist1 as data>","从数据库里读到的字段");//也可能会有其他方法来替换此标记,但是最终都是替换
就这样后台一个一个的替换最终生成一个替换好的string流再把这个流写入到一个文件里,并且此文件的扩展名为.html文件名根据本条数据的id(最好是id加栏目id)这样就完成了一个静态网页的生成
string temlpatestream=读到的模版流;
temlpatestream.replace("<#list datalist1 as data>","从数据库里读到的字段");//也可能会有其他方法来替换此标记,但是最终都是替换
就这样后台一个一个的替换最终生成一个替换好的string流再把这个流写入到一个文件里,并且此文件的扩展名为.html文件名根据本条数据的id(最好是id加栏目id)这样就完成了一个静态网页的生成
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
页面代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server" DataKeyField="Id"
oneditcommand="DataList1_EditCommand"
oncancelcommand="DataList1_CancelCommand"
onupdatecommand="DataList1_UpdateCommand">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="edit">编辑</asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="update">保存</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="cancel">取消</asp:LinkButton>
</EditItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
程序代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
this.DataList1.EditItemIndex = e.Item.ItemIndex;//显示编辑列
}
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{
string id = this.DataList1.DataKeys[e.Item.ItemIndex].ToString();//获取datakeys的值(id)
string info = ((TextBox)e.Item.FindControl("TextBox1")).Text;//获取textbox的值
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
{
this.DataList1.EditItemIndex = -1;//取消显示的编辑列
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server" DataKeyField="Id"
oneditcommand="DataList1_EditCommand"
oncancelcommand="DataList1_CancelCommand"
onupdatecommand="DataList1_UpdateCommand">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="edit">编辑</asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="update">保存</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="cancel">取消</asp:LinkButton>
</EditItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
程序代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
this.DataList1.EditItemIndex = e.Item.ItemIndex;//显示编辑列
}
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{
string id = this.DataList1.DataKeys[e.Item.ItemIndex].ToString();//获取datakeys的值(id)
string info = ((TextBox)e.Item.FindControl("TextBox1")).Text;//获取textbox的值
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
{
this.DataList1.EditItemIndex = -1;//取消显示的编辑列
}
}
}
追问
这段代码和我写的有关系吗?你写的那种我没有过,using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication1
{
这是什么程序?不明白,没用过
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询