I have problem , I add Button in Edit templete in form view1 and I put command accessdatasouce1.update . I find it is not working
I found No update happend and also No error I get it , I expect the command should be run from Accessdatasouce updatecommand specified in Aspx
please need your help , what is the missing ?
See the real code
ASPX code
Expand|Select|Wrap|Line Numbers
- <asp:AccessDataSource ID="AccessDataSource1" runat="server"
- DataFile="~/App_Data/DB.accdb"
- DeleteCommand="DELETE FROM [cargo] WHERE [código] = ?"
- InsertCommand="INSERT INTO [cargo] ([código], [cargo]) VALUES (?, ?)"
- SelectCommand="SELECT * FROM [cargo]"
- UpdateCommand="UPDATE [cargo] SET [cargo] = ? WHERE [código] = ?">
- <DeleteParameters>
- <asp:Parameter Name="código" Type="Int32" />
- </DeleteParameters>
- <InsertParameters>
- <asp:Parameter Name="código" Type="Int32" />
- <asp:Parameter Name="cargo" Type="String" />
- </InsertParameters>
- <UpdateParameters>
- <asp:Parameter Name="cargo" Type="String" />
- <asp:Parameter Name="código" Type="Int32" />
- </UpdateParameters>
- </asp:AccessDataSource>
- <asp:FormView ID="FormView1" runat="server" DataKeyNames="código"
- DataSourceID="AccessDataSource1">
- <EditItemTemplate>
- código:
- <asp:Label ID="códigoLabel1" runat="server" Text='<%# Eval("código") %>' />
- <br />
- cargo:
- <asp:TextBox ID="cargoTextBox" runat="server" Text='<%# Bind("cargo") %>' />
- <br />
- <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
- CommandName="Update" Text="Update" />
- <asp:LinkButton ID="UpdateCancelButton" runat="server"
- CausesValidation="False" CommandName="Cancel" Text="Cancel" />
- <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
- Text="Button" />
- </EditItemTemplate>
- <InsertItemTemplate>
- cargo:
- <asp:TextBox ID="cargoTextBox" runat="server" Text='<%# Bind("cargo") %>' />
- <br />
- <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
- CommandName="Insert" Text="Insert" />
- <asp:LinkButton ID="InsertCancelButton" runat="server"
- CausesValidation="False" CommandName="Cancel" Text="Cancel" />
- </InsertItemTemplate>
- <ItemTemplate>
- código:
- <asp:Label ID="códigoLabel" runat="server" Text='<%# Eval("código") %>' />
- <br />
- cargo:
- <asp:Label ID="cargoLabel" runat="server" Text='<%# Bind("cargo") %>' />
- <br />
- <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
- CommandName="Edit" Text="Edit" />
- <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
- CommandName="Delete" Text="Delete" />
- <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
- CommandName="New" Text="New" />
- </ItemTemplate>
- </asp:FormView>
VB :
Expand|Select|Wrap|Line Numbers
- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
- AccessDataSource1.Update()
- FormView1.ChangeMode(FormViewMode.ReadOnly)
- End Sub