在未能找到簡單的方法將消息推送給用戶之後,我決定使用我已在前端使用的按鈕發送更新。
<asp:Button ID="ApproveList"
runat="server"
style="width:200px;"
Text="Approve List"
CausesValidation="true"
OnClick="UpdateSelectedRecords_Click"
OnClientClick="return confirm('YOUR RECORDS WILL NOT BE APPROVED UNLESS ALL UNAPPROVED RECORDS HAVE A COMMENT. Are you sure you want to approve these records?');"/>
當用戶點擊該按鈕並確認他們希望繼續,其上運行的VB-側UpdateSelectedRecords_Click子。該子的第一部分檢查每一行的條件,如果發現任何問題,它只是結束子。
' Verify that every unchecked row has a comment, else fail
For Each row As GridViewRow In GridUnapprovedRecords.Rows
cb = CType(row.FindControl("CheckBox1"),CheckBox)
strComment = row.FindControl("Comment")
If Not cb.Checked Then
If strComment.Text Is Nothing Or Len(strComment.Text) = 0 Then
intErrors = intErrors + 1
End If
End If
Next
' If no unchecked boxes without comments, run updates
If intErrors = 0 Then
...
Else
Exit Sub
End If
我敢肯定,還有更多的選擇,但是這可以完成工作。
聽起來像你會在JavaScript中做的事情。一個gridview只是在瀏覽器中呈現爲一個表格,它很容易遍歷DOM來檢查每一行。 – Simon