Last post Feb 21, 2011 08:21 PM by als365
Feb 18, 2011 08:54 PM|als365|LINK
My SqlDataSource has no selectCommand defined in the .aspx page. Instead I define it in the code behind dynamically depending on some parameters that the user selects and then clicks a button to perform the query (custom search filters basically). The
problem is that when I click on a different page in my dataPager, or I click to sort any of the columns the gridview becomes empty when the page refreshes. I did a check and the selectCommand becomes empty when the page posts back. Is there a way to prevent
this from happening?
Feb 18, 2011 09:27 PM|WombatEd|LINK
Save your SelectCommand, or the data you need to reconstruct it, in ViewState. Then, in the pager's event handler, reconstruct it before you re-bind the grid.
Feb 21, 2011 08:21 PM|als365|LINK
Ok thanks Ed. I was originally thinking about doing that but I guess the real question I should have asked is whether or not the selectCommand for sqlDataSource is stored in the view state and the answer to that question, which I found after figuring out
what I was really trying to ask and doing some googling, is no. Here is a link to a workaround though.