PC Review


Reply
Thread Tools Rate Thread

DataGrid Update Doesn't Show Immediately

 
 
Wickwack
Guest
Posts: n/a
 
      22nd Jul 2003
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();
}

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C# webform doesn't update immediately Jason Huang Microsoft C# .NET 1 22nd Mar 2006 06:32 AM
How best to update DataAdapter to make DataGrid update immediately like table in Access would John Edens Microsoft Dot NET Framework Forms 1 5th Aug 2005 07:44 AM
Datagrid doesn't show XML data David Fúnez Microsoft Dot NET Compact Framework 12 29th Dec 2004 07:59 PM
SmartDocument: RefreshPane() doesn't update TaskPane immediately Beat Bucheli Microsoft Excel Programming 1 8th Jun 2004 05:11 PM
DataGrid ItemStyle is a textbox and doesn't update the datagrid datasource matthew schouppe Microsoft ASP .NET 3 30th Apr 2004 04:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:41 AM.