0

更新DetailsView后,点击DetailView上的Update Command按钮;我想将其中一个字段设置为“完成”。我在这里做错了什么?请。帮助。这是我背后的代码:

 Protected Sub Test(sender As Object, e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
        If IsPostBack Then
            Dim TextBox7 As TextBox = TryCast(DetailsView1.Rows(0).Cells(0).FindControl("TextBox7"), TextBox)
            TextBox7.Text = "Complete"
        End If
    End Sub
4

1 回答 1

0

我已经使用了这种方法并让它发挥作用。

Protected Sub PageDetailsView_ItemCommand(sender As Object, e As DetailsViewCommandEventArgs)
    If Me.PageDetailsView.DefaultMode = DetailsViewMode.[ReadOnly] Then  
        If e.CommandName.Equals("GenerateModifiedDate", StringComparison.CurrentCultureIgnoreCase) Then 
            Dim modifiedDateLabel As Label = TryCast(Me.PageDetailsView.FindControl("ModifiedDateLabel"), Label)
            modifiedDateLabel.Text = DateTime.Now.ToString()
        End If 
    Else
        If e.CommandName.Equals("GenerateModifiedDate", StringComparison.CurrentCultureIgnoreCase) Then
           Dim modifiedDateTextbox As TextBox = TryCast(Me.PageDetailsView.FindControl("ModifiedDateTextbox"), TextBox)
           modifiedDateTextbox.Text = DateTime.Now.ToString()
        End If 
    End If
End Sub
于 2012-10-30T20:32:18.293 回答