DataGrid Update Doesn't Show Immediately

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();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top