Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Capture click event for unbound checkbox
posted

I have tried searching the forums, but don't quite see the code for what I'm trying to do.  I have an web grid, and have added an unbound checkbox as the first column of the grid.  I have used this code:

gridAssigned.Columns.Insert(0, "UnAssign");

gridAssigned.Columns[0].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.CheckBox;

gridAssigned.DisplayLayout.Bands[0].Columns[0].Header.Caption = "UnAssign";

That works fine.  I don't need to save the values or be able to select all or anything.  All I want to do now is capture the event as soon as a checkbox is clicked and perform some action.  I am just not sure how to do this.  Do I need to set AllowUpdate to true?  Do I need to add something in the InitializeComponent?  I created a sub called

protected void gridAssigned_CellChange(object sender, CellEventArgs e)

 and put my code in there, but it never hits that.  Any help would be greatly appreciated.

Thanks!


           

 

  • 45049
    posted

    One possible thought - your new column might not be tracked in the grid's ViewState.  Try the following instead:

    using Infragistics.WebUI.UltraWebGrid;
    ...
    UltraGridColumn newColumn = new UltraGridColumn(true); // this "true" parameter means "track me in ViewState"
    newColumn.Key = "UnAssign"; // this was previously done when you used the Columns.Insert() method
    newColumn.Header.Caption = "UnAssign";
    gridAssigned.Columns.Insert(0, newColumn);

    AllowUpdate should be set to true, either for the column, the whole band, or the whole grid; otherwise, you won't be able to change the checkbox's value.

    I think you're also handling the wrong event.  WebGrid doesn't have a server-side CellChange event as far as I can see, unless it's a deprecated event that we no longer use in current versions.  As it is, you may need to use a client-side event handler, since I don't think there's any server-side event that will be raised the moment the checkbox is checked.

    See if that helps.  If it does not, we may need more information on your setup.