I have an unbound checkbox on the grid and based on a number of conditions I want to enable or disable the checkbox for that row. I think I need to run this during the InitializeRow event for the grid, but I'm not sure how to reference the unbound checkbox on the grid.
How do I reference the checkbox during the InitializeRow event?
Hello,
You can select the row from the event args of row initialize event and select the checkbox column based on index or a key by using the Items property.
protected void WebDataGrid1_OnInitializeRow(object sender, RowEventArgs e) { var checkbox = e.Row.Items.FindItemByKey("IsSelected"); checkbox.Value = true; }
I have attached sample for reference.
Let me know if I may be of further assistance.
I think that is very close to what I'm looking for. I have a bunch of conditions I'm looking at to enable or disable the checkbox. Is there an "enabled" or "visible" property I can use to disable the checkbox?
I have missunderstood your issue, that the goal is to change the value of the checkbox.
We have a blogpost on how to enable and disable checkboxes in the grid.
https://ko.infragistics.com/community/blogs/damyan_petev/archive/2014/03/07/multiple-enabled-and-disabled-checkbox-states-for-the-asp-net-ajax-data-grid.aspx
https://ko.infragistics.com/community/forums/t/75290.aspx
I used CSS to hide the checkbox, using the technique from the link above.