I'm using asp.net with c# code behind, and all I want to do is have a gridview+sqldatasource that I can manipulate at runtime and for whatever reason the buttons don't work. I have a login page that passes the username over via querystring and then this page is ONLY a gridview right now. When I click the delete button it immediately takes me to the login page with the fields blank again. For testing purposes I'm using just the delete button but I've had the same experience with the edit button as well, it never does the "update mode" like it seems it should.
<asp:GridView DataKeyNames="ID" ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" PageSize="8" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:WebMasterLogConnectionString2 %>'
SelectCommand="SELECT * FROM [WebmasterLogs] WHERE ([Username] = @Username) ORDER BY [ID]"
ConflictDetection="CompareAllValues"
DeleteCommand="DELETE FROM [WebmasterLogs] WHERE [ID] = @original_ID"
OldValuesParameterFormatString="original_{0}" >
<DeleteParameters>
<asp:Parameter Name="original_ID" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:QueryStringParameter Name="Username" QueryStringField="Username" Type="String" />
<asp:Parameter Name="LogEntryDate" Type="DateTime" />
<asp:Parameter Name="TimeSpent" Type="String" />
<asp:Parameter Name="Description" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
Web Config:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<connectionStrings>
<add name="WebMasterLogConnectionString" connectionString="Data Source=35sql;Initial Catalog=WebMasterLog;Persist Security Info=False;User ID=*****;Password=*********"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>