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="Steven Cheng[MSFT], post: 4262963"] Hi Scott, Thanks for your posting. As for the problem you mentioned, yes, just as you've mentioed, the DateSetIndex is the index of the DataSource binded to the DataGrid. And generally , when we bound a dataset or datatable onto a datagrid, the actual datasource (the datagrid binded with ) is a DataView, for DataTable, it's the DataTable's DefaultView , for DataSet, it'll be the DataSet's first table's defaultView if we don't specify a certain table in the dataset. That's why the e.Item.DateSetIndex is not the value of the index in DataSet. Also, as for the following things : ======================== 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. ========================= I think use PK to find the correct record is reasonable, and we don't need to loopthrough all the records in DataSet(in fact DataTable), the DataTable has a "Select" method which can help select DataRows via a simple SQL query string. For example: DataRow[] rows = ds.Tables[0].Select("Name = 'David'"); #DataTable.Select Method (String) [URL]http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataTableC[/URL] lassSelectTopic2.asp?frame=true Though this query engine is very simple, it'll be much better than we manually loop through all the rows. Hope helps. Thanks. Regards, Steven Cheng Microsoft Online Support Get Secure! [URL="http://www.microsoft.com/security"]www.microsoft.com/security[/URL] (This posting is provided "AS IS", with no warranties, and confers no rights.) [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ASP .Net Datagrid Control
e.Item.ItemIndex and e.Item.DataSetIndex
Top