Click here to Skip to main content
15,913,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Mr

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
ASP.NET
<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: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>



VB :

VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    AccessDataSource1.Update()
    FormView1.ChangeMode(FormViewMode.ReadOnly)

End Sub
Posted
Updated 3-Nov-11 21:36pm
v2

1 solution

Please check it by removing
VB
FormView1.ChangeMode(FormViewMode.ReadOnly)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900