I use TemplateField to create dropdownlist in 2nd column when in edit mode. but it cannot be find cell(1).control(0) when in RowUpdating event, only the cell(0) TextBox can be find. It shows the argument out of range exception. Anyone also face the same issue?
在编辑模式下,我使用Templatefield在第二列中创建下拉列表。但在RowUpdating事件中,只能找到单元格(0)文本框时,它不能是Find cell(1).control(0)。它显示参数超出范围异常。有没有人也面临同样的问题?
TemplateColumn = New TemplateField
TemplateColumn.ShowHeader = True
TemplateHeaderTxt = dicColumnMap(gDataTable.Columns.Item(i).Caption)
TemplateDataField = gDataTable.Columns.Item(i).Caption
TemplateColumn.HeaderTemplate = New GridViewTemplate(DataControlRowType.Header, TemplateHeaderTxt, "", "")
TemplateColumn.ItemTemplate = New GridViewTemplate(DataControlRowType.DataRow, TemplateDataField, TemplateDataField, "Label")
TemplateColumn.EditItemTemplate = New GridViewTemplate(DataControlRowType.DataRow, TemplateDataField, TemplateDataField, "DropDowmList", sqlConn)
Account_GridView.DataSource = gDataTable
Account_GridView.DataBind()
Private Sub Account_GridView_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles Account_GridView.RowUpdating
Dim row = Account_GridView.Rows(e.RowIndex)
Dim accountdate, payflow, member, typename, subtype, price, exchangeRate, comment, groupname, ID As String
Dim cnt = row.Cells.Count
accountdate = CType(row.Cells(0).Controls(0), TextBox).Text
payflow = CType(row.Cells(1).Controls(0), DropDownList).SelectedItem.Value
End Sub
I tried row.Cells(1).HasControls, but it shows false, it is obvious no object in 2nd column, it is so weird
我尝试了row.Cells(1).HasControls,但它显示为假,显然在第二列中没有对象,太奇怪了
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!