Voici donc mon code. Là où je rencontre le problème, mes champs de texte liés ne renvoient pas les informations à UpdateCommand comme prévu. Si je remplace l'un des @variables par du texte codé en dur, la mise à jour se produit comme prévu. Donc, si je remplace @RegID par '25', alors mon enregistrement est mis à jour avec succès mais vide car toutes les autres variables @variables étaient NULL au moment du traitement de la mise à jour. Où est mon erreur?Échec de la mise à jour ASP.NET FormView
<asp:FormView ID="formView" DataSourceID="Reg" runat="server" DataKeyNames="RegID" AllowPaging="true">
<ItemTemplate>
<h3 style="font-size:14px;"><%#Eval("Org") %></h3>
<table border="0">
<tr class="RowHighlight">
<td>Name:</td><td><%#Eval("Name") %></td>
</tr>
<tr>
<td>Phone Number:</td><td><%#Eval("PhoneNumber") %></td>
</tr>
<tr class="RowHighlight">
<td>Email Address:</td><td><%#Eval("EmailAddress")%></td>
</tr>
<tr>
<td>Address:</td><td><%#Eval("Address") %></td>
</tr>
<tr class="RowHighlight">
<td>Purchase Date:</td><td><%#Eval("MonthOfPurchase") + " " + Eval("YearOfPurchase")%></td>
</tr>
<tr>
<td>Notes:</td><td><%#Eval("Notes") %></td>
</tr>
<tr>
<td><asp:LinkButton ID="btnEdit" Text="Edit Details" runat="server" CommandName="Edit" /></td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<h3 style="font-size:14px;"><%#Eval("Org") %></h3>
<table border="0">
<tr>
<td>ID</td><td><%#Eval("RegID")%></td>
</tr>
<tr class="RowHighlight">
<td>Name:</td><td><asp:TextBox ID="txtName" runat="server" Width="100%" Text='<%# Bind("Name") %>' /></td>
</tr>
<tr>
<td>Phone Number:</td><td><asp:TextBox ID="txtPhoneNumber" runat="server" Width="100%" Text='<%# Bind("PhoneNumber") %>' /></td>
</tr>
<tr class="RowHighlight">
<td>Email Address:</td><td><asp:TextBox ID="txtEmailAddress" runat="server" Width="100%" Text='<%# Bind("EmailAddress") %>' /></td>
</tr>
<tr>
<td>Address:</td><td><asp:TextBox ID="txtAddress" runat="server" Width="100%" Text='<%# Bind("Address") %>' /></td>
</tr>
<tr class="RowHighlight">
<td>Month Of Purchase:</td><td><asp:TextBox ID="txtMonthOfPurchase" runat="server" Width="100%" Text='<%# Bind("MonthOfPurchase") %>' /></td>
</tr>
<tr>
<td>Year Of Purchase:</td><td><asp:TextBox ID="txtYearOfPurchase" runat="server" Width="100%" Text='<%# Bind("YearOfPurchase") %>' /></td>
</tr>
<tr class="RowHighlight">
<td>Notes:</td><td><%#Eval("Notes") %></td>
</tr>
<tr>
<td><asp:LinkButton ID="btnSave" Text="Save Changes" runat="server" CausesValidation="true" CommandName="Update" /></td>
<td><asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" /></td>
</tr>
</table>
</EditItemTemplate>
</asp:FormView>
<asp:SqlDataSource ProviderName="System.Data.Odbc" ID="Reg" runat="server"
ConnectionString="DRIVER={MySQL ODBC 3.51 Driver}; SERVER=<SERVER_NAME>; PORT=3306; DATABASE=<DATABASE> UID=<USERID>; PWD=<PASSWORD>; OPTION=3;"
SelectCommand="SELECT * FROM tblRegsitration
WHERE EmailSent=0 ORDER BY Org"
UpdateCommand="UPDATE tblRegsitration SET [email protected],
[email protected],
[email protected],
[email protected],
[email protected],
[email protected]
WHERE ([email protected])" />
Pouvez-vous envelopper manuellement les lignes de code avec les zones de texte, ils sont coupés et je n'ai pas assez réputation pour modifier votre poste. – Kendrick
Je ferai mieux la prochaine fois. Pour l'instant le problème est résolu. Merci. – Jeff