DetailView控件ItemUpdating事件里的不到值!
在ItemUpdating事件中 DetailsViewUpdateEventArgs e 里Keys,NewValues,OldValues里总是没有值!请各位看看!using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Bind();
}
}
private void Bind()
{
String[] keys = new String[] { "ID" };
this.DetailsView1.DataSource = this.CreateDataSource();
this.DetailsView1.DataKeyNames = keys;
this.DetailsView1.DataBind();
}
private DataTable CreateDataSource()
{
DataTable data = new DataTable();
data.Columns.Add("ID");
data.Columns.Add("Code");
data.Columns.Add("Name");
data.Columns.Add("Age");
DataRow d = data.NewRow();
d["ID"] = 1;
d["Code"]="001";
d["Name"]="User1";
d["Age"] = 27;
data.Rows.Add(d);
return data;
}
protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
{
Response.Write(e.CommandName);
}
protected void DetailsView1_ModeChanging(object sender, DetailsViewModeEventArgs e)
{
Response.Write("ModeChanging");
((DetailsView)sender).ChangeMode((DetailsViewMode)e.NewMode);
this.Bind();
}
protected void DetailsView1_ModeChanged(object sender, EventArgs e)
{
Response.Write("ModeChanged");
}
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
//e里面没有人数据!keys,NewValues,和OldValues里都没有值!
Response.Write("Updating");
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
--------------------编程问答-------------------- TextBox tbLogContext = (TextBox)this.DetailsView1.FindControl("txt_cust_ed");
Response.Write(TextBox tbLogContext);
試一試
补充:.NET技术 , ASP.NET