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
105
WebDataGrid 11.ASP.Net Grid column objects not available after code-behind databind until user physically selects the grid
posted

I have an aspx page with code-behind which uses a javascript to trap the "enter" key when a user is searching for records.

When the user hits enter the search is performed and the datasource is updated with the results in a WebDataGrid which do appear on the page correctly. 

By default I have made it so all the results are selected in the grid and when the user clicks a process button, I read the grid's columns and do stuff to the data. The column objects aren't present when I call :

this.Master.GetGridSelectedColValue(grdSearch, "myGridColumnName");

this method returns this:  Invalid column name: Object reference not set to an instance of an object.

If the user interacts with the grid by selecting a single record and re-selecting all of them and clicking the same process button on the page, then all the objects for the columns are instantiated and accessible in code-behind.

Adding a grid.DataBind() immediately before accessing the column values has no effect.