Get RepositoryLookupEdit from GridView
I'd like to iterate through all the rows in a gridview and retrieve data from RepositoryLookupEdit.
Basically I'd like to do this, but I don't know how to get the RepositoryLookupEdit:
For i as Int32 = 0 to myGridView.RowCount -1
Dim row As DataRowView = CType(myGridView.GetRow(i), DataRowView)
//'This next line does not work
Dim lue As LookUpEdit = row.Item("myColumn").myRepLookupEdit
Dim drv As DataRowView = CType(editor.Properties.GetDataSourceRowByKeyValue(lue.EditVal开发者_Python百科ue), DataRowView)
Dim myData As Int32 = CType(drv("myData"), Int32)
Next
I think that you should use the following code:
For i as Int32 = 0 to myGridView.RowCount -1
Dim cellValue As object = myGridView.GetRowCellValue(i, "myColumn")
dim dView as DataView = new DataView(repositoryItemGridLookupEdit.DataSource) ' you should pass a DataTable instance here
dim rowIndex as integer = dView.Find(cellValue)
dim otherCellValue as object = dview(rowIndex)("myData")
Next
Does this work for you?
精彩评论