views:

1800

answers:

1

Hi all,

I have a GridView that is bound to an ObjectDataSource, and I am handling the full row select using the standard solution provdided all over of putting this line in the OnRowDataBound():

e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackEventReference(this, "Select$" + e.Row.RowIndex);

All of this is working swimmingly, except that I am noticing my ObjectDataSource is being hit each time the row selection changes. I am not doing a BindData() anywhere in the row selection code behind, and since the data isn't changing as a result of the select I really don't see why the grid needs to rebind. I am letting the gridview handle paging and sorting, but again, selection doesn't change the contents so I don't think that should effect it.

I have tried turning the view state on for the grid (very small amount of data) and it had no effect. I set the UpdatePanel to conditional updates and children as triggers=false, but that caused the data to still be queried but no update to occur to the screen (LOL!).

Any GridView gurus out there want to take a stab at this one?

+1  A: 

Are you missing the following in your Page_Load():

If (!IsPostBack)
{

}

This is something developers miss a lot! Follow your events and you'll likely see that somewhere an event is fired OnPostBack and you're calling your DB code.

Gavin Miller
As it turns out no... but it would not have surpised me! LOL. I think I've decided that the page is way to complicated to boil down to a simple example, and it's working as is, and I'm not passing the data in view state this way, so I've decided to be happy. Thanks though! :-)
John