WebGrid 7 Template Column Control ClientID Numbering Inconsistent

12 replies. Last post: October 26, 2009 11:24 AM by A Yousif
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
A YousifMember

We have a major problem that's cropped up and we need help as it's rendering our grids unusable.  Our grids are customized with the first column always a check box.  This is a Template column that hosts our own custom check box control.  The issue I'm about to describe only occurs when the page is loaded without a post back.  It works fine when it is a post back.

Each embedded check box has the generic ID of PrismCheckBoxRowChecker.  The ClientID is something like ctl00_ctl00_WebPaneManager1_ViewLeftSide_Content_View_PrismGridViewControl_ctl00_PrismCheckBoxRowChecker.

The problem upon loading the grid without a post back is that the ClientID portion that is serialized, i.e., ctl00, ctl01, ctl02, etc. is inconsistent and makes no sense.  Some pages the initial page load would load fine and in order.  But on other pages it may load in increments of 2 or 3 or 4 and so on which I don't understand.  So the initial controls on the page may have the ctl00, ctl02, ctl04, ctl06, etc.  which would be fine if it stayed consistent on post back.  However, it does not.

On post back, it works correctly every time, i.e., the controls are serialized correctly as ctl00, ctl01, ctl02, etc.  This creates a BIG problem because if the second row is checked and the page was rendered in, let's say, increments of 3, then the second control would be ctl03.  On post back, however, this id represents the fourth control and would then render the selected item useless because it doesn't match.  On some grids the initial load works just fine.

In the InstantiateIn method of our ITemplate control, the check box is created and added to the container.Controls collection.  Below is an example of the container.Parent.Controls collection after the check box control is added via container.Controls.Add.

After the first Add, here's what's in the container.Parent.Controls:
ctl00_ctl00_WebPaneManager1_ViewLeftSide_Content_View_PrismGridViewCtl_ctl00

After the second check box is added, here's what's there in addition to the line above:
ctl00_ctl00_WebPaneManager1_ViewLeftSide_Content_View_PrismGridViewCtl_ctl00_PrismCheckBoxRowChecker
ctl00_ctl00_WebPaneManager1_ViewLeftSide_Content_View_PrismGridViewCtl_ctl01
ctl00_ctl00_WebPaneManager1_ViewLeftSide_Content_View_PrismGridViewCtl_ctl01_ctl00
ctl00_ctl00_WebPaneManager1_ViewLeftSide_Content_View_PrismGridViewCtl_ctl02

Why is this last control, ctl02, being added?  I'm wondering if there's a bug in the underlying WebGridCellTemplateContainer code?  This continues as the controls are added, i.e., after the third check box is added, the last controls is then:
ctl00_ctl00_WebPaneManager1_ViewLeftSide_Content_View_PrismGridViewCtl_ctl04

Please help.  Let me know what other information I can provide.

[EDIT] I did try a standard check box, i.e., System.Web.UI.WebControls.CheckBox and the behavior was the same by the way.  Our templated class is this:

public class PrismGridViewCheckBoxColumn : ITemplate

and it implements InstantiateIn as such:

public void InstantiateIn(System.Web.UI.Control container)

 

All times are GMT -5. The time now is 10:32 AM.
Previous Next