asp.net Repeater控件中放一个asp:Button如何通过asp:Button操作该行?
展开全部
前台
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeater获取控件.aspx.cs" Inherits="repeater获取控件" %>
<!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 runat="server">
<title>test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="Repeater1_ItemCommand"
>
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("A") %>'></asp:TextBox>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" CommandName="get" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db_10ConnectionString3 %>"
SelectCommand="SELECT * FROM [test126]"></asp:SqlDataSource>
</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;
public partial class repeater获取控件 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("get"))
{
TextBox text = e.Item.FindControl("TextBox1") as TextBox;
Response.Write(text.Text);
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeater获取控件.aspx.cs" Inherits="repeater获取控件" %>
<!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 runat="server">
<title>test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="Repeater1_ItemCommand"
>
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("A") %>'></asp:TextBox>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" CommandName="get" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:db_10ConnectionString3 %>"
SelectCommand="SELECT * FROM [test126]"></asp:SqlDataSource>
</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;
public partial class repeater获取控件 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("get"))
{
TextBox text = e.Item.FindControl("TextBox1") as TextBox;
Response.Write(text.Text);
}
}
}
追问
我写了一个存储过程不知道哪里错了 ,能看一下否?
create procedure select_systemcategory
(
@ParentId int,
@page int,
@pagesize int
)
as
declare @topex int
select @topex=@pagesize*(@page-1)
select top @pagesize * from SystemLogCategory
where Id not in (select top @topex Id from SystemLogCategory)
go
追答
create PROCEDURE [dbo].[select_systemcategory]
(
@ParentId int,
@page int,
@pagesize int
)
AS
BEGIN
declare @topex int
select @topex=@pagesize*(@page-1)
declare @sql nvarchar(max)
set @sql='select top '+cast(@pagesize as varchar)+' * from SystemLogCategory where Id not in( select top '+cast(@topex as varchar)+ 'Id from SystemLogCategory)'
exec(@sql)
END
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询