Intercepting GridView event argument from update panel

Posted on: Wed Oct 01 17:01:23 -0700 2008. Updated on: Wed Oct 01 17:09:06 -0700 2008.
Category: Asp .Net AJAX / Javascript / CSS

Let's say we have a gridview within an UpdatePanel. The GridView throws some command arguments, ie Edit, Delete, or a Custom LinkButton in a template field with it's CommandArgument set.

When the GridView's command arguments are fired, only the things in that UpdatePanel will get updated, nothing else. So if we want to intercept that call and for example refresh another update panel we would do the following:

First set up you update panel like this:


Your Gridview with it's command arguments goes in here...


Now define the OnLoad function for the updatepanel.

protected void UpdatePanelList_Load(object sender, EventArgs e)
{
   if (String.IsNullOrEmpty(Request.Params.Get("__EVENTARGUMENT")) == false)
   {
      // We are gonna pull the commandargument that is coming in as an eventargument from the GV
      int itemId = 0;
      Int32.TryParse(Request.Params.Get("__EVENTARGUMENT"), out itemId);
      // Now we can execute something with that code, or update a different update panel.
      LoadSomething(itemId);
   }
}

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.