Unable to Update using DetailsView or Gridview [closed]

Bug252

New Member
I am unable to edit using a detailsview. I have a detailsview that is connected to a gridview and displayed on modalpopup. The detailsview is already shown in insert mode to update the information already stored in the database. The connection between the gridview and the detailsview works fine with "Select" but when I try to update nothing happens, the Update button doesn't update. No postback happen and I get no error messages. I am not sure if my issue is coming from the database or the query itself. I am using a SQL Server Express 2008 database to connect these objects.Am I doing something incorrectly or is it my update code?\[code\]<asp:UpdatePanel ID="Updateinstructor" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Timer ID="Timer5" runat="server" Interval="3000"> </asp:Timer> <asp:GridView ID="gvinstructor" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="InstructorID" DataSourceID="SqlDataSource17" OnSelectedIndexChanged="gvinstructor_SelectedIndexChanged" SelectedIndex="0" Width="880px" CellPadding="4" ForeColor="#333333" GridLines="None"> <AlternatingRowStyle BackColor="White" /> <Columns> <... Bound fields...> </Columns> </asp:GridView> <br /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer5" EventName="Tick" /> </Triggers> </asp:UpdatePanel> <asp:Button ID="buttoninstructors" runat="server" style="display:none"/> <asp:ModalPopupExtender ID="Modalinstructors" runat="server" DynamicServicePath="" Enabled="True" BackgroundCssClass="modalBackground" PopupControlID="UpdatePanelDetailsView5" TargetControlID="buttoninstructors"> </asp:ModalPopupExtender> <br /> <br /> <asp:SqlDataSource ID="SqlDataSource17" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:WildLife_EducationConnectionString %>" DeleteCommand="DELETE FROM [tblInstructor] WHERE [InstructorID] = @original_InstructorID AND (([InstructorLastName] = @original_InstructorLastName) OR ([InstructorLastName] IS NULL AND @original_InstructorLastName IS NULL)) AND (([InstructorFirstName] = @original_InstructorFirstName) OR ([InstructorFirstName] IS NULL AND @original_InstructorFirstName IS NULL)) AND (([InstructorMiddleInitial] = @original_InstructorMiddleInitial) OR ([InstructorMiddleInitial] IS NULL AND @original_InstructorMiddleInitial IS NULL)) AND (([InstructorSuffix] = @original_InstructorSuffix) OR ([InstructorSuffix] IS NULL AND @original_InstructorSuffix IS NULL)) AND (([InstructorEmail] = @original_InstructorEmail) OR ([InstructorEmail] IS NULL AND @original_InstructorEmail IS NULL)) AND (([InstructorPhoneNumber] = @original_InstructorPhoneNumber) OR ([InstructorPhoneNumber] IS NULL AND @original_InstructorPhoneNumber IS NULL))" InsertCommand="INSERT INTO [tblInstructor] ([InstructorLastName], [InstructorFirstName], [InstructorMiddleInitial], [InstructorSuffix], [InstructorEmail], [InstructorPhoneNumber]) VALUES (@InstructorLastName, @InstructorFirstName, @InstructorMiddleInitial, @InstructorSuffix, @InstructorEmail, @InstructorPhoneNumber)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [tblInstructor]" UpdateCommand="UPDATE [tblInstructor] SET [InstructorLastName] = @InstructorLastName, [InstructorFirstName] = @InstructorFirstName, [InstructorMiddleInitial] = @InstructorMiddleInitial, [InstructorSuffix] = @InstructorSuffix, [InstructorEmail] = @InstructorEmail, [InstructorPhoneNumber] = @InstructorPhoneNumber WHERE [InstructorID] = @original_InstructorID AND (([InstructorLastName] = @original_InstructorLastName) OR ([InstructorLastName] IS NULL AND @original_InstructorLastName IS NULL)) AND (([InstructorFirstName] = @original_InstructorFirstName) OR ([InstructorFirstName] IS NULL AND @original_InstructorFirstName IS NULL)) AND (([InstructorMiddleInitial] = @original_InstructorMiddleInitial) OR ([InstructorMiddleInitial] IS NULL AND @original_InstructorMiddleInitial IS NULL)) AND (([InstructorSuffix] = @original_InstructorSuffix) OR ([InstructorSuffix] IS NULL AND @original_InstructorSuffix IS NULL)) AND (([InstructorEmail] = @original_InstructorEmail) OR ([InstructorEmail] IS NULL AND @original_InstructorEmail IS NULL)) AND (([InstructorPhoneNumber] = @original_InstructorPhoneNumber) OR ([InstructorPhoneNumber] IS NULL AND @original_InstructorPhoneNumber IS NULL))" > <UpdateParameters> <asp:Parameter Name="InstructorLastName" Type="String" /> <asp:Parameter Name="InstructorFirstName" Type="String" /> <asp:Parameter Name="InstructorMiddleInitial" Type="String" /> <asp:Parameter Name="InstructorSuffix" Type="String" /> <asp:Parameter Name="InstructorEmail" Type="String" /> <asp:Parameter Name="InstructorPhoneNumber" Type="String" /> <asp:Parameter Name="original_InstructorID" Type="Int32" /> <asp:Parameter Name="original_InstructorLastName" Type="String" /> <asp:Parameter Name="original_InstructorFirstName" Type="String" /> <asp:Parameter Name="original_InstructorMiddleInitial" Type="String" /> <asp:Parameter Name="original_InstructorSuffix" Type="String" /> <asp:Parameter Name="original_InstructorEmail" Type="String" /> <asp:Parameter Name="original_InstructorPhoneNumber" Type="String" /> </UpdateParameters> </asp:SqlDataSource> <br /> <asp:SqlDataSource ID="SqlDataSource11" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:WildLife_EducationConnectionString %>" DeleteCommand="DELETE FROM [tblInstructor] WHERE [InstructorID] = @original_InstructorID AND (([InstructorLastName] = @original_InstructorLastName) OR ([InstructorLastName] IS NULL AND @original_InstructorLastName IS NULL)) AND (([InstructorFirstName] = @original_InstructorFirstName) OR ([InstructorFirstName] IS NULL AND @original_InstructorFirstName IS NULL)) AND (([InstructorMiddleInitial] = @original_InstructorMiddleInitial) OR ([InstructorMiddleInitial] IS NULL AND @original_InstructorMiddleInitial IS NULL)) AND (([InstructorSuffix] = @original_InstructorSuffix) OR ([InstructorSuffix] IS NULL AND @original_InstructorSuffix IS NULL)) AND (([InstructorEmail] = @original_InstructorEmail) OR ([InstructorEmail] IS NULL AND @original_InstructorEmail IS NULL)) AND (([InstructorPhoneNumber] = @original_InstructorPhoneNumber) OR ([InstructorPhoneNumber] IS NULL AND @original_InstructorPhoneNumber IS NULL))" InsertCommand="INSERT INTO [tblInstructor] ([InstructorLastName], [InstructorFirstName], [InstructorMiddleInitial], [InstructorSuffix], [InstructorEmail], [InstructorPhoneNumber]) VALUES (@InstructorLastName, @InstructorFirstName, @InstructorMiddleInitial, @InstructorSuffix, @InstructorEmail, @InstructorPhoneNumber)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [tblInstructor]" UpdateCommand="UPDATE [tblInstructor] SET [InstructorLastName] = @InstructorLastName, [InstructorFirstName] = @InstructorFirstName, [InstructorMiddleInitial] = @InstructorMiddleInitial, [InstructorSuffix] = @InstructorSuffix, [InstructorEmail] = @InstructorEmail, [InstructorPhoneNumber] = @InstructorPhoneNumber WHERE [InstructorID] = @original_InstructorID AND (([InstructorLastName] = @original_InstructorLastName) OR ([InstructorLastName] IS NULL AND @original_InstructorLastName IS NULL)) AND (([InstructorFirstName] = @original_InstructorFirstName) OR ([InstructorFirstName] IS NULL AND @original_InstructorFirstName IS NULL)) AND (([InstructorMiddleInitial] = @original_InstructorMiddleInitial) OR ([InstructorMiddleInitial] IS NULL AND @original_InstructorMiddleInitial IS NULL)) AND (([InstructorSuffix] = @original_InstructorSuffix) OR ([InstructorSuffix] IS NULL AND @original_InstructorSuffix IS NULL)) AND (([InstructorEmail] = @original_InstructorEmail) OR ([InstructorEmail] IS NULL AND @original_InstructorEmail IS NULL)) AND (([InstructorPhoneNumber] = @original_InstructorPhoneNumber) OR ([InstructorPhoneNumber] IS NULL AND @original_InstructorPhoneNumber IS NULL))"> <UpdateParameters> <asp:Parameter Name="InstructorLastName" Type="String" /> <asp:Parameter Name="InstructorFirstName" Type="String" /> <asp:Parameter Name="InstructorMiddleInitial" Type="String" /> <asp:Parameter Name="InstructorSuffix" Type="String" /> <asp:Parameter Name="InstructorEmail" Type="String" /> <asp:Parameter Name="InstructorPhoneNumber" Type="String" /> <asp:Parameter Name="original_InstructorID" Type="Int32" /> <asp:Parameter Name="original_InstructorLastName" Type="String" /> <asp:Parameter Name="original_InstructorFirstName" Type="String" /> <asp:Parameter Name="original_InstructorMiddleInitial" Type="String" /> <asp:Parameter Name="original_InstructorSuffix" Type="String" /> <asp:Parameter Name="original_InstructorEmail" Type="String" /> <asp:Parameter Name="original_InstructorPhoneNumber" Type="String" /> </UpdateParameters> </asp:SqlDataSource> <asp:UpdatePanel ID="UpdatePanelDetailsView5" runat="server" UpdateMode="Conditional"> <ContentTemplate> <br /> <asp:DetailsView ID="dvinstructor" runat="server" AutoGenerateRows="False" DataKeyNames="InstructorID" DataSourceID="SqlDataSource11" GridLines="None" Height="50px" <Fields> <...Bound fields...> <EditItemTemplate> <br /> <br /> <asp:Button ID="Button13" runat="server" CausesValidation="True" CommandName="Update" Text="Update" Width="80px" /> &nbsp;&nbsp;&nbsp; <asp:Button ID="Button14" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" Width="80px" /> </EditItemTemplate> <ItemTemplate> <br /> <br /> <asp:Button ID="Button15" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" Width="80px" /> </ItemTemplate> </asp:TemplateField> </Fields> </asp:DetailsView> <br /> </ContentTemplate> </asp:UpdatePanel>using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class Default2 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) Updateinstructor.Update();}protected void gvinstructor_SelectedIndexChanged(object sender, EventArgs e){ dvinstructor.PageIndex = gvinstructor.SelectedIndex;}protected void Linknuttoninstructorselect_Click(object sender, EventArgs e){ LinkButton btnSelect2 = sender as LinkButton; GridViewRow row = (GridViewRow)btnSelect2.NamingContainer; this.SqlDataSource17.SelectParameters.Clear(); this.dvinstructor.DataBind(); this.UpdatePanelDetailsView5.Update(); this.Modalinstructors.Show();}}\[/code\]
 
Back
Top