在数据绑定中显示表中的行 [英] Display rows from a table in Databound
本文介绍了在数据绑定中显示表中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我后面有一个弹出式窗口的代码,该窗口从表w1中显示....我试图找到一种方法,可以显示来自tabl w1的所有行,因为现在它仅显示1行..任何人都知道怎么做?谢谢
Hi I have code behind for a pop windows which displays from table w1....I was trying to find a way where it can display all the rows from tabl w1 cause right now it only displays 1 row..anyone know how to do that? thanks
public partial class Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=xxx.xx.xxx.xxx;Initial Catalog=x;Uid=t;Password=xxx;");
SqlCommand cmd;
SqlDataReader dr;
TextBox email = new TextBox();
protected void Page_Load(object sender, EventArgs e)
{
email.Text = "" + Session["email"];
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
con.Open();
cmd = new SqlCommand("SELECT C, P, t, FROM w1 WHERE email='" + email.Text + "'", con);
dr = cmd.ExecuteReader();
con.Close();
}
}
推荐答案
SqlDataSource1_Selecting
中的代码无效.如果要从数据源填充表w1,则需要更改 SelectCommand [ ^ ].
The code in SqlDataSource1_Selecting
serves nothing. If you are populating table w1 from datasource then you need to change the SelectCommand[^] in datasource.
这篇关于在数据绑定中显示表中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文