W
Wickwack
Hi,
I'm using Matrix Web for ASP.NET. I have a datagrid which I am using
with the edit feature. When I click the OK button, the database gets
updated. This part works. However, when the page loads up, the
datagrid displays the old data. If I refresh the page, or go to edit
another item, the changed data appears. What am I doing wrong?
Here is my updater function.
--
void Languages_Update(object sender, DataGridCommandEventArgs e) {
SqlConnection conn = new SqlConnection("Data Source=WICKWACK; User
Id=XXX; Password=XXX; Database=chorallibrary");
conn.Open();
SqlCommand updateCmd = new SqlCommand("usp_UpdateLanguages",conn);
updateCmd.CommandType = CommandType.StoredProcedure;
SqlParameter myParam =
updateCmd.Parameters.Add("@RowCount",SqlDbType.Int);
myParam.Direction = ParameterDirection.ReturnValue;
myParam = updateCmd.Parameters.Add("@LanguageId",SqlDbType.Int,0);
myParam.Value = DataGrid_Languages.DataKeys[e.Item.ItemIndex];
myParam =
updateCmd.Parameters.Add("@LanguageName",SqlDbType.NVarChar,50);
myParam.Value = ((TextBox)(e.Item.Cells[0].Controls[0])).Text;
updateCmd.ExecuteNonQuery();
conn.Close();
Int32 rowCount = (Int32) updateCmd.Parameters["@RowCount"].Value;
Message.Text = "You successfully updated "+rowCount+" rows.";
DataGrid_Languages.EditItemIndex=-1;
DataGrid_Languages.DataBind();
}
I'm using Matrix Web for ASP.NET. I have a datagrid which I am using
with the edit feature. When I click the OK button, the database gets
updated. This part works. However, when the page loads up, the
datagrid displays the old data. If I refresh the page, or go to edit
another item, the changed data appears. What am I doing wrong?
Here is my updater function.
--
void Languages_Update(object sender, DataGridCommandEventArgs e) {
SqlConnection conn = new SqlConnection("Data Source=WICKWACK; User
Id=XXX; Password=XXX; Database=chorallibrary");
conn.Open();
SqlCommand updateCmd = new SqlCommand("usp_UpdateLanguages",conn);
updateCmd.CommandType = CommandType.StoredProcedure;
SqlParameter myParam =
updateCmd.Parameters.Add("@RowCount",SqlDbType.Int);
myParam.Direction = ParameterDirection.ReturnValue;
myParam = updateCmd.Parameters.Add("@LanguageId",SqlDbType.Int,0);
myParam.Value = DataGrid_Languages.DataKeys[e.Item.ItemIndex];
myParam =
updateCmd.Parameters.Add("@LanguageName",SqlDbType.NVarChar,50);
myParam.Value = ((TextBox)(e.Item.Cells[0].Controls[0])).Text;
updateCmd.ExecuteNonQuery();
conn.Close();
Int32 rowCount = (Int32) updateCmd.Parameters["@RowCount"].Value;
Message.Text = "You successfully updated "+rowCount+" rows.";
DataGrid_Languages.EditItemIndex=-1;
DataGrid_Languages.DataBind();
}