I am creating a custom gridview control which has a custom CheckBoxTemplateField column (deriving from TemplateField class). This template field column has custom Checkboxheadertemplate (implementing ITemplate) and CheckboxItemTemplate (also implementing ITemplate). In InstantiateIn method of both templates (header as well as Item template), I am adding a checkbox control which has Autopostback = true.
My requirement is:
I want to mark all the values in the binding column of datasource if checkbox in headertemplate is checked. I dont want to mark only rows visible on grid. I WANT TO MARK ALL ROWS IN DATASOURCE. I want to do this in _CheckedChanged event of checkbox in header template.
Problem I am facing: When I check/uncheck the checkbox in header, it postbacks. so in OnCheckedChanged event, gridview's datasource is null. Secondly, in any event of gridview, I could access only those rows of datasource for which corresponding rows are visible in gridview through Gridviewrow.DataItem property. But I want to set it for all rows in datasource.
Please suggest me a way to do this.
View Complete Post