我用list给DetailsView添加数据,就是修改不了
usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingS...
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using ErpModels;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=Erp;User ID=sa;Password=chenzhilong99985"))
{
List<Admin> adminlist = new List<Admin>();
try
{
SqlCommand command = new SqlCommand("dbo.UP_t_admin_info_GetModel", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@aid", SqlDbType.VarChar, 16).Value = "admin";
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Admin admin = new Admin();
admin.aid = Convert.ToString(reader[0]);
admin.password = Convert.ToString(reader[1]).Trim();
admin.email = Convert.ToString(reader[2]).Trim();
admin.phone = Convert.ToString(reader[3]).Trim();
admin.mobile = Convert.ToString(reader[4]).Trim();
admin.role = Convert.ToString(reader[5]).Trim();
adminlist.Add(admin);
}
this.DetailsView1.DataSource = adminlist;
DataBind();
}
finally
{
connection.Close();
connection.Dispose();
}
}
}
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
string aa = (this.DetailsView1.FindControl("TextBox5") as TextBox).Text;
}
}
在页面修改后,这个aa 的值读出来还是原来的值 展开
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using ErpModels;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=Erp;User ID=sa;Password=chenzhilong99985"))
{
List<Admin> adminlist = new List<Admin>();
try
{
SqlCommand command = new SqlCommand("dbo.UP_t_admin_info_GetModel", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@aid", SqlDbType.VarChar, 16).Value = "admin";
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Admin admin = new Admin();
admin.aid = Convert.ToString(reader[0]);
admin.password = Convert.ToString(reader[1]).Trim();
admin.email = Convert.ToString(reader[2]).Trim();
admin.phone = Convert.ToString(reader[3]).Trim();
admin.mobile = Convert.ToString(reader[4]).Trim();
admin.role = Convert.ToString(reader[5]).Trim();
adminlist.Add(admin);
}
this.DetailsView1.DataSource = adminlist;
DataBind();
}
finally
{
connection.Close();
connection.Dispose();
}
}
}
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
string aa = (this.DetailsView1.FindControl("TextBox5") as TextBox).Text;
}
}
在页面修改后,这个aa 的值读出来还是原来的值 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询