[英]Refreshing gridview after update
I am having trouble trying to get my gridview to refresh after I update it. 我在更新网格视图时尝试刷新网格视图时遇到麻烦。 The DB takes the updates and I can see them there when I manually refresh the page, but not when I click the update link to commit the changes.
数据库接收更新,并且当我手动刷新页面时可以在此处看到更新,但是当我单击更新链接以提交更改时看不到它们。
I tried to call the function that fills the grid, I receive a js error "Microsoft JScript runtime error: Unable to get value of the property 'firstChild': object is null or undefined". 我试图调用填充网格的函数,但收到一个js错误“ Microsoft JScript运行时错误:无法获取属性'firstChild'的值:对象为null或未定义”。 It runs through the method and doesn't throw that error until after it has exited.
它运行方法,直到退出后才抛出该错误。
Is there another approach that I can take to refresh my grid after Update? 在更新后,是否可以使用另一种方法来刷新网格?
Here is the code: 这是代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindCustodiansByProjectID();
BindCustodianMedia(EditMediaClass.outRequestMediaID);
}
}
private void BindCustodianMedia(string MediaID)
{
DataTable dt = new DataTable();
SqlConnection conn = new SqlConnection(GetConnString());
DataSet ds = new DataSet();
try
{
conn.Open();
SqlCommand cmd = new SqlCommand("usps_displayEditMedia_CustodianMedia", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@aspMediaID", SqlDbType.Int)).Value = int.Parse(MediaID);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
grd_custodianMedia.DataSource = ds;
grd_custodianMedia.DataBind();
}
protected void updateCustodianMedia_OnUpdateCommand(object sender, GridRecordEventArgs e)
{
SqlConnection conn = new SqlConnection(GetConnString());
conn.Open();
try
{
SqlCommand cmd = new SqlCommand("usps_updateCustodianMedia_EditMedia", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@aspCustodianMediaID", SqlDbType.Int)).Value = int.Parse(e.Record["CustodianMediaID"].ToString());
cmd.Parameters.Add(new SqlParameter("@aspMediaID", SqlDbType.Int)).Value = int.Parse(EditMediaClass.outRequestMediaID.ToString());
cmd.Parameters.Add(new SqlParameter("@aspCustodianID", SqlDbType.Int)).Value = int.Parse(e.Record["CustodianID"].ToString());
cmd.Parameters.Add(new SqlParameter("@aspUploadPath", SqlDbType.VarChar)).Value = e.Record["UploadPath"];
cmd.Parameters.Add(new SqlParameter("@aspDataSize", SqlDbType.VarChar)).Value = e.Record["DataSize"];
cmd.Parameters.Add(new SqlParameter("@aspDataDesc", SqlDbType.VarChar)).Value = e.Record["DataDescription"];
cmd.ExecuteNonQuery();
//BindCustodianMedia(EditMediaClass.outRequestMediaID);
}
For Javascript error, try to debug with Firebug
or IE developer tools and find out exactly which line is causing you the issue. 对于Javascript错误,请尝试使用
Firebug
或IE开发人员工具进行调试,并找出导致问题的确切原因。 You are trying access a property "firstchild" from an object which is null. 您正在尝试从null对象访问属性“ firstchild”。 With this information it is very hard to tell which could be the exact problem.
有了这些信息,很难确定哪个可能是确切的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.