This program:
edit select delete id etc.
(outside under gridview)
textbox1
textbox2
addbutton cancelbutton
]
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="id"
BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px"
CellPadding="3" GridLines="Vertical" >
<RowStyle BackColor="#EEEEEE" ForeColor="Black"/>
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:Button ID="Button2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
<asp:Button ID="Button2" runat="server" CausesValidation="False"
CommandName="Select" Text="Select" />
<asp:Button ID="Button3" runat="server" CausesValidation="False"
CommandName="Delete" Text="Cancel" OnClientClick="return confirm('Are you sure');"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False"
ReadOnly="True" SortExpression="id" Visible="False" />
<asp:BoundField DataField="sysaccount" HeaderText="sysaccount"
SortExpression="sysaccount" />
<asp:BoundField DataField="syspw" HeaderText="syspw" SortExpression="syspw" />
<asp:BoundField DataField="log" HeaderText="log" SortExpression="log" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="System Manager"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="26px"></asp:TextBox>
<br />
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Height="26px"></asp:TextBox>
<br />
<br />
<br />
<br />
<asp:Button ID="Button4" runat="server"
style="font-size: large; font-family: Times New Roman; font-weight: 700" Text="Add" />
<asp:Button ID="Button5" runat="server"
style="font-size: large; font-family: Times New Roman; font-weight: 700" Text="Cancel" />
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim sqlupdate As String
Dim con1 As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\Users\user\Desktop\honor.mdb")
sqlupdate = "UPDATE sysdep SET sysaccount= @sysaccount, syspw= @syspw WHERE id= @id"
Dim cmd1 As New OleDbCommand(sqlupdate, con1)
Dim id As String = (GridView1.Rows(e.RowIndex).Cells(0).ToString)
Dim account As String = (GridView1.Rows(e.RowIndex).Cells(1).ToString)
Dim pw As String = (GridView1.Rows(e.RowIndex).Cells(2).ToString)
cmd1.Parameters.Add(New OleDbParameter("@sysaccount", account))
cmd1.Parameters.Add(New OleDbParameter("@syspw", pw))
cmd1.Parameters.Add(New OleDbParameter("@id", id))
Try
con1.Open()
cmd1.ExecuteNonQuery()
Catch ex As OleDbException
MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
Catch ex As InvalidOperationException
MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Web")
End Try
con1.Close()
GridView1.EditIndex = -1
BindGridView()
End Sub
I got all buttons working except the gridview1_rowupdating?
Thanks.