We help IT Professionals succeed at work.

How to redirect after gridview row updating?

Hello Experts,

I use the following on a button to redirect the user to the same page when it's clicked:

protected void btn_refresh_emp_name_ddl_Click(object sender, EventArgs e)
        {
            Response.Redirect(Request.RawUrl);
        }

Open in new window

I would like to do the same thing when a gridview row is updated, so I tried this:

protected void tbl_emp_gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Response.Redirect(Request.RawUrl);
        } 

Open in new window

but it didn't work.  

Any help would be greatly appreciated.

Thanks,
J
Comment
Watch Question

Developer
Top Expert 2015
Commented:
Hi,

why do you want to redirect to same page after updating?

after updating what do you want to do?

If you want to Update Your Grid, Please call GridView1.DataBind();
Kaushal AroraTechnical Analyst
Commented:
Dear ferguson,

The solution provided by Lokesh is correct if you want to show the updated data only after updating.

If you still want to redirect, kindly do it in the RowUpdated Event and use the below code for that.

Response.Redirect(Request.RawUrl, false);

Open in new window


False is added so that the code written after Response.Redirect should not get executed.

Hope this helps you.

Regards,
Kaushal Arora

Author

Commented:
Thanks!  That's what I needed.