0
我有一個包含UpdatePanel和5個GridViews的頁面。我在Gridview外部有一個刪除按鈕,可以快速刪除多個文件。是否有可能爲所有的GridView使用一個刪除按鈕點擊事件?更新面板中包含多個GridQuery的Delete_Click事件
Protected Sub deletePacketBtn_Click(sender As Object, e As EventArgs) Handles deletePacketBtn.Click
'Loop through all the rows in gridview
For Each gvrow As C1GridViewRow In packetGrid.Rows
'Finiding checkbox control in gridview for particular row
Dim chkdelete As CheckBox = CType(gvrow.FindControl("chkDelete"), CheckBox)
'Condition to check checkbox selected or not
If chkdelete.Checked Then
'Getting ID of particular row using datakey value
Dim fileID As Integer = Convert.ToInt32(packetGrid.DataKeys(gvrow.RowIndex).Value)
PacketDataSource.DeleteParameters("original_PKT_Key").DefaultValue = fileID.ToString
PacketDataSource.Delete()
End If
Next
packetGrid.DataBind()
End Sub
數據源特定於單個網格的情況如何。我將如何處理這個參數'KEY'是不同的? –
如果一切都不一樣,你最終會在你的一個'Delete'處理程序中擁有如此多的條件邏輯,這樣你就會更加簡潔並且更容易混淆,因爲每個網格都有5個獨立的'Delete'處理程序。 –
我剛剛嘗試將GridView作爲發件人進行投射,並且出現錯誤「Unable to cast type .... button to .... GridView。」。我想避免爲Delete方法使用多個按鈕,並且不必隱藏它們,以等待可見的網格。 –