JeroenDortmans
Technical User
Hello,
I have a GridView made with VS 2005 with an edit function.
When I use the edit function and change data and click on update most of the time the data is not updated in the database. There have been situations that I was able to update the data of one row but most of the time this was not possible.
The delete function works fine.
I don´t know what the problem is and I don´t know how to solve it, please help!
Here the code I use:
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="OverzichtProgramma.aspx.cs" Inherits="login_OverzichtProgramma3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Aanpassen Programma</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: left">
<br />
<table style="width: 100%">
<tr>
<td colspan="3" style="margin-top: 15px; margin-left: 15px; width: 100%; text-align: center">
<strong><span style="font-size: 24pt">
Overzicht Programma</span></strong></td>
</tr>
</table>
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Default.aspx">Terug</asp:HyperLink><br />
<asp:SqlDataSource ID="Programma" runat="server" ConnectionString="<%$ ConnectionStrings:VVBOSKANT_DEV_ConnectionString %>"
ProviderName="<%$ ConnectionStrings:VVBOSKANT_DEV_ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Programma] ORDER BY [Datum], [Tijd]" DeleteCommand="DELETE FROM [Programma] WHERE [ProgrammaID] = ?" UpdateCommand="UPDATE [Programma] SET [Datum] = ?, [Tijd] = ?, [TeamThuis] = ?, [TeamUit] = ?, [DoelpuntenThuis] = ?, [DoelpuntenUit] = ?, [Opmerkingen] = ?, [ZichtbaarProgramma] = ?, [Oefenwedstrijd] = ? WHERE [ProgrammaID] = ? AND [Datum] = ? AND [Tijd] = ? AND [TeamThuis] = ? AND [TeamUit] = ? AND [DoelpuntenThuis] = ? AND [DoelpuntenUit] = ? AND [Opmerkingen] = ? AND [ZichtbaarProgramma] = ? AND [Oefenwedstrijd] = ?" OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
<DeleteParameters>
<asp
arameter Name="original_ProgrammaID" Type="Int32" />
<asp
arameter Name="original_Datum" Type="DateTime" />
<asp
arameter Name="original_Tijd" Type="String" />
<asp
arameter Name="original_TeamThuis" Type="String" />
<asp
arameter Name="original_TeamUit" Type="String" />
<asp
arameter Name="original_DoelpuntenThuis" Type="Int32" />
<asp
arameter Name="original_DoelpuntenUit" Type="Int32" />
<asp
arameter Name="original_Opmerkingen" Type="String" />
<asp
arameter Name="original_ZichtbaarProgramma" Type="Boolean" />
<asp
arameter Name="original_Oefenwedstrijd" Type="Boolean" />
</DeleteParameters>
<UpdateParameters>
<asp
arameter Name="Datum" Type="DateTime" />
<asp
arameter Name="Tijd" Type="String" />
<asp
arameter Name="TeamThuis" Type="String" />
<asp
arameter Name="TeamUit" Type="String" />
<asp
arameter Name="DoelpuntenThuis" Type="Int32" />
<asp
arameter Name="DoelpuntenUit" Type="Int32" />
<asp
arameter Name="Opmerkingen" Type="String" />
<asp
arameter Name="ZichtbaarProgramma" Type="Boolean" />
<asp
arameter Name="Oefenwedstrijd" Type="Boolean" />
<asp
arameter Name="original_ProgrammaID" Type="Int32" />
<asp
arameter Name="original_Datum" Type="DateTime" />
<asp
arameter Name="original_Tijd" Type="String" />
<asp
arameter Name="original_TeamThuis" Type="String" />
<asp
arameter Name="original_TeamUit" Type="String" />
<asp
arameter Name="original_DoelpuntenThuis" Type="Int32" />
<asp
arameter Name="original_DoelpuntenUit" Type="Int32" />
<asp
arameter Name="original_Opmerkingen" Type="String" />
<asp
arameter Name="original_ZichtbaarProgramma" Type="Boolean" />
<asp
arameter Name="original_Oefenwedstrijd" Type="Boolean" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ProgrammaID" DataSourceID="Programma"
ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField CancelText="Annuleren" EditText="Aanpassen" ShowEditButton="True" />
<asp:TemplateField FooterText="Verwijderen">
<ItemTemplate>
<asp:LinkButton ID="btnDelete" Text="Verwijderen" runat="server"
OnClientClick="return confirm('Weet je zeker dat je deze wedstrijd met bijbehorende informatie wil verwijderen?');"
CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Datum" SortExpression="Datum">
<ControlStyle Width="60px" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Datum", "{0:d}") %>' Width="60px"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Datum" runat="server" Text='<%# Bind("Datum", "{0:d}") %>' Width="60px" ToolTip='Vul een datum in, voorbeeld: "dd-mm-yy"'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="*" ControlToValidate="Datum" Font-Size="X-Large"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tijd" SortExpression="Tijd">
<EditItemTemplate>
<asp:TextBox ID="Tijd" runat="server" Text='<%# Bind("Tijd") %>' ToolTip='Vul een tijd in, voorbeeld: "xx:xx"'
Width="50px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Tijd"
ErrorMessage="*" Font-Size="X-Large"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Tijd") %>' Width="50px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TeamThuis" HeaderText="Team Thuis" SortExpression="TeamThuis" />
<asp:BoundField DataField="TeamUit" HeaderText="Team Uit" SortExpression="TeamUit" />
<asp:BoundField DataField="DoelpuntenThuis" HeaderText="DP Thuis" SortExpression="DoelpuntenThuis" >
<ControlStyle Width="20px" />
</asp:BoundField>
<asp:BoundField DataField="DoelpuntenUit" HeaderText="DP Uit" SortExpression="DoelpuntenUit" >
<ControlStyle Width="20px" />
</asp:BoundField>
<asp:BoundField DataField="Opmerkingen" HeaderText="Opmerkingen" SortExpression="Opmerkingen" />
<asp:CheckBoxField DataField="ZichtbaarProgramma" HeaderText="Toon op site" SortExpression="ZichtbaarProgramma" InsertVisible="False" />
<asp:CheckBoxField DataField="Oefenwedstrijd" HeaderText="Oefenwedstrijd" SortExpression="Oefenwedstrijd" InsertVisible="False" />
</Columns>
<RowStyle BackColor="#EFF3FB" Font-Names="Arial" Font-Size="Small" />
<EditRowStyle BackColor="LightSkyBlue" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Size="Medium" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
</form>
</body>
</html>
Code behind:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class login_OverzichtProgramma3 : System.Web.UI.Page
{
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
I have a GridView made with VS 2005 with an edit function.
When I use the edit function and change data and click on update most of the time the data is not updated in the database. There have been situations that I was able to update the data of one row but most of the time this was not possible.
The delete function works fine.
I don´t know what the problem is and I don´t know how to solve it, please help!
Here the code I use:
<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="OverzichtProgramma.aspx.cs" Inherits="login_OverzichtProgramma3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Aanpassen Programma</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: left">
<br />
<table style="width: 100%">
<tr>
<td colspan="3" style="margin-top: 15px; margin-left: 15px; width: 100%; text-align: center">
<strong><span style="font-size: 24pt">
Overzicht Programma</span></strong></td>
</tr>
</table>
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Default.aspx">Terug</asp:HyperLink><br />
<asp:SqlDataSource ID="Programma" runat="server" ConnectionString="<%$ ConnectionStrings:VVBOSKANT_DEV_ConnectionString %>"
ProviderName="<%$ ConnectionStrings:VVBOSKANT_DEV_ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [Programma] ORDER BY [Datum], [Tijd]" DeleteCommand="DELETE FROM [Programma] WHERE [ProgrammaID] = ?" UpdateCommand="UPDATE [Programma] SET [Datum] = ?, [Tijd] = ?, [TeamThuis] = ?, [TeamUit] = ?, [DoelpuntenThuis] = ?, [DoelpuntenUit] = ?, [Opmerkingen] = ?, [ZichtbaarProgramma] = ?, [Oefenwedstrijd] = ? WHERE [ProgrammaID] = ? AND [Datum] = ? AND [Tijd] = ? AND [TeamThuis] = ? AND [TeamUit] = ? AND [DoelpuntenThuis] = ? AND [DoelpuntenUit] = ? AND [Opmerkingen] = ? AND [ZichtbaarProgramma] = ? AND [Oefenwedstrijd] = ?" OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
<DeleteParameters>
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
</DeleteParameters>
<UpdateParameters>
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ProgrammaID" DataSourceID="Programma"
ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField CancelText="Annuleren" EditText="Aanpassen" ShowEditButton="True" />
<asp:TemplateField FooterText="Verwijderen">
<ItemTemplate>
<asp:LinkButton ID="btnDelete" Text="Verwijderen" runat="server"
OnClientClick="return confirm('Weet je zeker dat je deze wedstrijd met bijbehorende informatie wil verwijderen?');"
CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Datum" SortExpression="Datum">
<ControlStyle Width="60px" />
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Datum", "{0:d}") %>' Width="60px"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Datum" runat="server" Text='<%# Bind("Datum", "{0:d}") %>' Width="60px" ToolTip='Vul een datum in, voorbeeld: "dd-mm-yy"'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="*" ControlToValidate="Datum" Font-Size="X-Large"></asp:RequiredFieldValidator>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tijd" SortExpression="Tijd">
<EditItemTemplate>
<asp:TextBox ID="Tijd" runat="server" Text='<%# Bind("Tijd") %>' ToolTip='Vul een tijd in, voorbeeld: "xx:xx"'
Width="50px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Tijd"
ErrorMessage="*" Font-Size="X-Large"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Tijd") %>' Width="50px"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TeamThuis" HeaderText="Team Thuis" SortExpression="TeamThuis" />
<asp:BoundField DataField="TeamUit" HeaderText="Team Uit" SortExpression="TeamUit" />
<asp:BoundField DataField="DoelpuntenThuis" HeaderText="DP Thuis" SortExpression="DoelpuntenThuis" >
<ControlStyle Width="20px" />
</asp:BoundField>
<asp:BoundField DataField="DoelpuntenUit" HeaderText="DP Uit" SortExpression="DoelpuntenUit" >
<ControlStyle Width="20px" />
</asp:BoundField>
<asp:BoundField DataField="Opmerkingen" HeaderText="Opmerkingen" SortExpression="Opmerkingen" />
<asp:CheckBoxField DataField="ZichtbaarProgramma" HeaderText="Toon op site" SortExpression="ZichtbaarProgramma" InsertVisible="False" />
<asp:CheckBoxField DataField="Oefenwedstrijd" HeaderText="Oefenwedstrijd" SortExpression="Oefenwedstrijd" InsertVisible="False" />
</Columns>
<RowStyle BackColor="#EFF3FB" Font-Names="Arial" Font-Size="Small" />
<EditRowStyle BackColor="LightSkyBlue" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Size="Medium" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
</form>
</body>
</html>
Code behind:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class login_OverzichtProgramma3 : System.Web.UI.Page
{
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}