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[0].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.CheckBox;
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!
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() methodnewColumn.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.
I got it working a few minutes after writing my question. I did the same as what I was saying in my post, but I guess I had the syntax wrong at first. Basically, I created the new column with:
gridAssigned.Columns.Insert(0, "UnAssign"); gridAssigned.Columns[0].Type = Infragistics.WebUI.UltraWebGrid.ColumnType.CheckBox;
Then I added:
gridAssigned.DisplayLayout.AllowUpdateDefault = AllowUpdate.No;gridAssigned.Columns[0].AllowUpdate = AllowUpdate.Yes;
This is so the update would occur only when I clicked the check box, not any other cell of the grid.
Then, I had the following:
and it hit that every time I clicked the checkbox. So I guess the only thing I was missing was the AllowUpdate. I don't know if CellChange is depracated or not, but it is working fine for what I need to do. I am using version 2007, vol 3 of the grid.