本文介绍了asp.net用于设计和部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="rptrTable" runat="server"
onitemcommand="rptrTable_ItemCommand" >
<HeaderTemplate>
<table border=3>
<tr>
<th>Agent ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>City</th>
<th>SSN</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem,"AgentID") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"FirstName") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"LastName") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"City") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"SSN") %>
</td>
<td>
<asp:Button ID="btnShow" runat="server" Text="Show" CommandName="ShowButt" CommandArgument='<%# Eval("AgentID") %>' />
</td>
<td>
<asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="EditButt" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
我的.cs文件是
my .cs file is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
SqlConnection connection;
SqlCommand command;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strcon = ConfigurationManager.ConnectionStrings["AgentConn"].ConnectionString;
connection = new SqlConnection(strcon);
command = new SqlCommand("prcAgentShow", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
DataTable dt = new DataTable();
SqlDataReader dataReader = command.ExecuteReader();
dt.Load(dataReader);
rptrTable.DataSource = dt;
rptrTable.DataBind();
}
}
protected void rptrTable_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("ShowButt"))
{
Label1.Text = "u clik the show button ";
}
}
}
从sorce文件中的按钮显示应具有应返回LABEL1的AgentID怎么办?
请如何帮助
from sorce file button show having AgentID THAT SHOULD RETURN TO LABEL1 HOW ?
HOW PLEASE HELP
推荐答案
protected void rptrTable_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "ShowButt")
{
Label1.Text = e.CommandArgument.ToString();
}
}
这篇关于asp.net用于设计和部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!