3

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 This is how I add a datasource to 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!

2 Answers 2

1

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

here is the MSDN article....

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" />
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks Shafqat but this article doesn't answer my question. I got objectdatasource working and only want to return flags on success or failure.
kindly implement updated and inserted events of the objectdatasource and using ObjectDataSourceStatusEventArgs e.ReturnValue you can get the return value
Hi mate, I tried to do that but still didn't work. This is what i did protected void GridView1_RowUpdated(object sender, ObjectDataSourceStatusEventArgs e) { Label1.Text = (string)e.ReturnValue; }
hi dnt use row updated i am talking about the implementation of updated event for objectdatasource
1

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" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.