62,047
社区成员
发帖
与我相关
我的任务
分享
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ghypnus.bs.test._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 id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server">
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table cellpadding="3" cellspacing="3">
<tr>
<td>ID</td><td>COUNT</td><td>PRICE</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="13" cellspacing="13">
<tr>
<td><asp:Label ID="lbl_ID" runat="Server" Text='<%#Eval("ID") %>'></asp:Label></td>
<td><asp:Label ID="lbl_COUNT" runat="Server" Text='<%#Eval("Count") %>'></asp:Label></td>
<td><asp:Label ID="Lbl_PRICE" runat="Server" Text='<%#Eval("Price") %>'></asp:Label></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
后台测试数据:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn dc = null;
dc = dt.Columns.Add("ID");
dc = dt.Columns.Add("Count");
dc = dt.Columns.Add("Price");
DataRow dr = dt.NewRow();
dr["ID"] = 1;
dr["Count"] = 2;
dr["Price"] = 3;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["ID"] = 4;
dr["Count"] = 5;
dr["Price"] = 6;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["ID"] = 7;
dr["Count"] = 8;
dr["Price"] = 9;
dt.Rows.Add(dr);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
this.Repeater1.DataSource = dt;
this.Repeater1.DataBind();
foreach (RepeaterItem rs in Repeater1.Items)
{
string str_ID = ((Label)rs.FindControl("lbl_ID")).Text;
string str_Count = ((Label)rs.FindControl("lbl_COUNT")).Text;
string str_Price = ((Label)rs.FindControl("Lbl_PRICE")).Text;
string str_Message = "ID:" + str_ID + " Count:" + str_Count + " Price:" + str_Price;
Response.Write("<script>alert('" + str_Message + "')</script>");
}
}
begin transaction
declare @TotalError int --定义变量,用于累计事务执行过程中的错误
/**//*--循环处理--*/
while()
begin
end
set @TotalError =@TotalError +@@error --累计是否有错误
insert into a values(6,3)
set @TotalError =@TotalError +@@error --累计是否有错误
--根据是否有错误,确定事务是提交还是回滚--
if @TotalError >0
begin
rollback transaction
end
else
begin
commit transaction
end