We help IT Professionals succeed at work.

Run web control code before the parent page code

jrmcintosh
jrmcintosh asked
on
195 Views
Last Modified: 2008-04-24
I have a web control within a page that has multiple datagrids in it. Within these data grids is a button column that allows users to delete data. When I click on this button column it does not go directly to the call I have to delete the data but rather refreshes the parent page. How do I force it to run the web control code first?

Thanks,
Jason


Private Sub dgage_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgage.ItemCommand

        If e.CommandName = "DeleteRec" Then
            Try
                'Delete metric and reload dgs

                Dim db As Database = DatabaseFactory.CreateDatabase()
                Dim cmd As DBCommandWrapper
                Dim sqlCommand As String
                sqlCommand = "usp_del_metric"
                cmd = db.GetStoredProcCommandWrapper(sqlCommand)
                cmd.AddInParameter("@rec_id", DbType.String, e.Item.Cells(3).Text)
                cmd.AddOutParameter("@metcount", DbType.Int32, 8)
                db.ExecuteNonQuery(cmd)

                LoadDGs()

            Catch err As Exception
                Dim log As New Framework.Logging(err.GetType.ToString(), err.Source, err.Message, err.StackTrace, Environment.MachineName)
            End Try
        End If
    End Sub
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008

Commented:
Let's see if I understand.

You click on a button in a DataGrid, and the page posts back.  You want to do the code immediately.  

If that is true, it is not going to happen server-side, it would have to happen client-side with Javascript or AJAX calls.

Bob
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
oops, somehow accidentally clicked submit :)

and then, you can write code in your event handlers, and the normal page_load code won't execute when you 'post back'....like in your 'dgage_ItemCommand'.

where you can delete the data, and then bind the data again afterwards
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.