dataview的編輯,更新,刪除,取消等事件

html 文件:
 <asp:GridView ID="GVA" runat="server" AutoGenerateColumns="False" BackColor="White"
            BorderColor
="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="0" CellSpacing="1"
            GridLines
="Horizontal" Style="font-size: 11pt; text-align: center">
            
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
            
<Columns>
                
<asp:BoundField DataField="c0" HeaderText="類別" />
                
<asp:BoundField DataField="c1" HeaderText="名稱" />
                
<asp:BoundField DataField="c2" HeaderText="數目" />
                
<asp:CommandField ShowEditButton="True" />
                
<asp:CommandField ShowDeleteButton="True" />
            
</Columns>
            
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
            
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
            
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
            
<AlternatingRowStyle BackColor="#F7F7F7" />
        
</asp:GridView>

code:
 Protected Sub GVA_RowEditing(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GVA.RowEditing

        GVA.EditIndex 
= e.NewEditIndex
        fail_gv(
"682")
        
Dim i As Integer
        
For i = 0 To GVA.Rows.Count - 1
            
CType(GVA.Rows(i).Cells(3).Controls(0), LinkButton).Attributes.Add("onclick""var e=window.confirm('更新嗎?');if(e){return true;}else{return false;}")
        
Next
    
End Sub


    
Protected Sub GVA_RowCancelingEdit(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GVA.RowCancelingEdit
        
Me.GVA.EditIndex = -1
        fail_gv(
"682")
        
Dim i As Integer
        
For i = 0 To GVA.Rows.Count - 1
            
CType(GVA.Rows(i).Cells(3).Controls(0), LinkButton).Attributes.Add("onclick""var e=window.confirm('編輯11嗎?');if(e){return true;}else{return false;}")
        
Next
    
End Sub



    
Protected Sub GVA_RowUpdating(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GVA.RowUpdating
        
Me.GVA.EditIndex = -1
        fail_gv(
"682")
        
Dim i As Integer
        
For i = 0 To GVA.Rows.Count - 1
            
CType(GVA.Rows(i).Cells(3).Controls(0), LinkButton).Attributes.Add("onclick""var e=window.confirm('編輯12嗎?');if(e){return true;}else{return false;}")
        
Next
    
End Sub


    
Protected Sub GVA_RowDeleting(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVA.RowDeleting
        GVA.EditIndex 
= -1
        fail_gv(
"682")
        
'Dim i As Integer
        'For i = 0 To GVA.Rows.Count - 1
        '    CType(GVA.Rows(i).Cells(3).Controls(0), LinkButton).Attributes.Add("onclick", "var e=window.confirm('更新嗎?');if(e){return true;}else{return false;}")
        'Next
    End Sub
posted @ 2006-07-05 10:39  Nina  阅读(1939)  评论(0)    收藏  举报