Reputation: 932
I am using a showGrid in an ASP website that is linked to a dataSource (class in the business logic). the dataSource has two methods - Retrieve and Update.
When I update an item on the showGrid it automatically sends the parameters of the updated row to the method and then I use the method to update the database.
How can I return a message to the presentation logic saying that it has successfully updated? everything is done automatically and I don't even use the GridView1_RowUpdating handler and can't find how communications happen between the showGrid and dataSource.
This is how I added the method as a dataSource for the showGrid
and this is the function that get's called
public bool UpdateSpecificSubject(string sj_name, string sJ_descr, Int32 sj_max_enrollment_no, bool sj_avail, string sj_prerequisite_no, string sj_id)
{
try
{
SubjectsDSTableAdapters.subjectsTableAdapter subjectsAdapter1 = new SubjectsDSTableAdapters.subjectsTableAdapter();
subjectsAdapter1.UpdateOneSubject(sj_name, sJ_descr, sj_max_enrollment_no, sj_avail, sj_id);
subjectsAdapter1.UpdatePrerequisite(sj_prerequisite_no, sj_id);
return true;
}
catch (Exception)
{
Console.Write("Error in connecting to Subjects table");
return false;
}
}
Any help would be appreciated... Thanks!
Upvotes: 3
Views: 847
Reputation: 8438
I had the very same problem. What appeared to be was that you need to use the events onUpdated and Oninserted referring to the ObjectDataSource that you use in your code. The ObjectDataSourceStatusEventArgs will then return the value as e.ReturnValue.
<asp:ObjectDataSource OnUpdated="ObjectDataSourceStatusEventHandler" />
Upvotes: 1
Reputation: 2570
to understand the working of grdiview and datasource, you need to go though this article
as you are binding the class so right now you only need to focus on objectdatasource
To get the return value from the function in your class.. kindly implement the following events Updated and Inserted of ObjectDataSource. and ObjectDataSourceStatusEventArgs event argument will return the Return value as e.ReturnValue.
<asp:ObjectDataSource OnUpdated="ObjectDataSourceStatusEventHandler" />
Upvotes: 1