Another note- for your production page, if you decide to use Data Key Names and you're not autogenerating your grid columns, the Grid View will assume your datakeys are sensitive and will ask the page to encrypt its viewstate, which is a perf hit.If you don't need to hide your datakey values from your clients, you can tell the page you don't want viewstate encrypted by setting the page directive View State Encryption Mode to Never instead of Auto.For security reasons, we no longer databind fields that aren't visible, as you've noticed.If Data Key Names is set, we request that the page encrypts the contents of View State and Control State.If you make a simple gridview with 2 columns and make both columns visible, you cn use the code below to get the value.When you set visible="false" in the file, the value is no longer populated and str0 returns an empty string.If you're using callbacks (post-Beta 2), Data Keys will also get stored in another hidden field on your page because Control State can't be updated within a callback, and sorting and paging will influence the contents of the Data Keys property.Data Keys do get stored in page state so they're available on postback.
In the On Data Bound event, you can retrieve the key values.But it looks like there is a problem with this approach. If I click some row (Command Button or Link Button) right away, then Data Keys array gets populated and everything is fine, but if I click on page link first and after page gets reloaded try to click on some row - here we go, Data Keys. If so, then yes, it's a bug that's been fixed, but it didn't make it into Beta 2. My workaround for this bug is to use custom commands and bind value of id to Command Argument property.Data Keys array doesn't get populated if I use paging and I process postback not from the first page. I described my solution here: Post.aspx#900598 Setting table cell width to less than the space it takes to render out its content will not work in most browsers- it will just auto-resize to the smallest size it needs to render your content.This has the added benefit of saving off the real value of the field rather than the To String() representation of the value.I understand your reasons to not databind hidden fields and use Data Keys array instead. Are you setting the Data Source property rather than the Data Source ID property? Right, it doesn't work only if Data Source property assgined.If you don't want those fields in the Keys dictionary passed to the data source, you can remove them from the Keys dictionary in a handler for those events. What I meant to ask is that in the case of Select events you can use the Grid View. Edit Index inside of the Row Editing event i used the Grid View Edit Event Args. str0 returns the id_file, but str1 errors saying: Unable to cast object of type 'System. Most people don't realize that the contents of an invisible field are sent to the client in readable format. The bug was that we cleared out the data keys when not bound to a data source control when handling the paging event.