还有一段显示子类表的,重复数据不能显求的问题就在这里
//test1.aspx.cs
………………………
private void Page_Load(object sender, System.EventArgs e)
{
fid=Int32.Parse(Request.Params["fid"]);
XDown.nClasss mynclass=new XDown.nClasss();
OleDbDataReader myReader=mynclass.GetChildList(fid);
if(myReader.HasRows)
{
DataList1.DataSource=myReader;
DataList1.DataBind();
}
else
{
Response.Write("没有值");
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
XDown.nClasss mynclass=new XDown.nClasss();
if(mynclass.AddChildKind(fid,TextBox1.Text))
{
DataList1.DataSource=mynclass.GetChildList(fid);
DataList1.DataBind();
Response.Write("添加成功");
}
else
{
Response.Write("添加失败");
}
………………………
//test1.aspx.cs
………………………
private void Page_Load(object sender, System.EventArgs e)
{
fid=Int32.Parse(Request.Params["fid"]);
XDown.nClasss mynclass=new XDown.nClasss();
OleDbDataReader myReader=mynclass.GetChildList(fid);
if(myReader.HasRows)
{
DataList1.DataSource=myReader;
DataList1.DataBind();
}
else
{
Response.Write("没有值");
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
XDown.nClasss mynclass=new XDown.nClasss();
if(mynclass.AddChildKind(fid,TextBox1.Text))
{
DataList1.DataSource=mynclass.GetChildList(fid);
DataList1.DataBind();
Response.Write("添加成功");
}
else
{
Response.Write("添加失败");
}
………………………
--〉添加后转到显示页面就可以了!
就是在本页 button_click事件里触发
我的做法是在 button_click事件里重新对 DataList进行绑定,但时好,时坏
但是现在我发现是DataList 有个非常奇怪的问题主是我添加的数据一条能显示,一条不能显示(数据库里是添加进去的)
我用DataGrid 来绑定就没有问题,
DataGrid 与DataList 用的是同一个DataView
万分不解,还请高手帮忙
http://210.83.119.69/net/test1.aspx?fid=1
http://expert.csdn.net/Expert/topic/2128/2128157.xml?temp=.1925012
曾答应过只要解决问题把100分都给解决问题的 人