在改写repeater控件中将一列数据采用链接方式,点击后查询相关列的详细信息,怎么实现?
2个回答
展开全部
这个很简单呀
aspx文件:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<a href='default.aspx?ID=<%#Eval("EmployeeID") %>'><%#Eval("LastName") %></a><br />
</ItemTemplate>
</asp:Repeater>
——————————————————————————————
aspx.cs文件:
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection("Server=.;database=northwind;uid=sa;pwd=123"))
{
SqlCommand comm = new SqlCommand("Select * from employees", conn);
SqlDataAdapter sda = new SqlDataAdapter(comm);
DataTable dt = new DataTable();
sda.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
aspx文件:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<a href='default.aspx?ID=<%#Eval("EmployeeID") %>'><%#Eval("LastName") %></a><br />
</ItemTemplate>
</asp:Repeater>
——————————————————————————————
aspx.cs文件:
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection("Server=.;database=northwind;uid=sa;pwd=123"))
{
SqlCommand comm = new SqlCommand("Select * from employees", conn);
SqlDataAdapter sda = new SqlDataAdapter(comm);
DataTable dt = new DataTable();
sda.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询