Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
ASP .Net Datagrid Control
e.Item.ItemIndex and e.Item.DataSetIndex
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Scott M., post: 4262959"] When writing the update event handler for a web forms DataGrid, I am running into a situation that is giving me quite the headache! If a user has sorted the items in a DataGrid and then chooses to edit one of the items, I have found that e.Item.ItemIndex and e.Item.DataSetIndex will both return the same number even when (in most cases) the item's number in the DataSet is different than the item's number in the DataGrid. I supsect that this has something to do with the fact that after a sort, the grid is bound to a DataView, so when you ask for the e.Item.DataSetIndex, you are really getting the index in the DataView. This behavior does not occur when no sort has occured but the user has changed from one page index to another. In those cases, the e.Item.ItemIndex will return (correctly) the index of the item in the DataGrid and e.Item.DataSetIndex will return (correctly) the index of the item in the DataSet. What I've had to do to solve the problem when a grid has sorting and paging turned on is to loop through the DataSet numerically, looking for records that have the same primary key value in the DataSet as the one being edited. This works, but there must be a better (more effieicent) way. Has anyone else run into this? What do you suggest? Why doesn't "e.Item.DataSetIndex" always produce the value it implies it produces? Thanks! [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ASP .Net Datagrid Control
e.Item.ItemIndex and e.Item.DataSetIndex
Top