我在更新后尝试刷新我的 gridview 时遇到问题。数据库获取更新,当我手动刷新页面时我可以在那里看到它们,但当我单击更新链接提交更改时看不到它们。
我试图调用填充网格的函数,我收到一个 js 错误“Microsoft JScript 运行时错误:无法获取属性‘firstChild’的值:对象为空或未定义”。它运行该方法并且在退出之前不会抛出该错误。
更新后我可以采取另一种方法来刷新我的网格吗?
这是代码:
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);
}