GridView Not Updating

Joined
Mar 14, 2009
Messages
1
Reaction score
0
I am having the problem that whenever I try to update GridView using generated SQL queries, it doesn't update. My code:

<%@ Page Title="" Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true" CodeFile="Users.aspx.cs" Inherits="Users" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Username"
DataSourceID="SqlDataSource1" GridLines="Vertical">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Username" HeaderText="Username" ReadOnly="True"
SortExpression="Username" />
<asp:BoundField DataField="Password" HeaderText="Password"
SortExpression="Password" />
<asp:TemplateField HeaderText="Memberlevel" SortExpression="Memberlevel">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource2" DataTextField="Memberlevel"
DataValueField="Memberlevel">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Memberlevel") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Stables" HeaderText="Stables"
SortExpression="Stables" />
<asp:BoundField DataField="PrefixSuffix" HeaderText="PrefixSuffix"
SortExpression="PrefixSuffix" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:MHR %>"
DeleteCommand="DELETE FROM [Users] WHERE [Username] = @original_Username AND [Password] = @original_Password AND [Memberlevel] = @original_Memberlevel AND [Stables] = @original_Stables AND (([PrefixSuffix] = @original_PrefixSuffix) OR ([PrefixSuffix] IS NULL AND @original_PrefixSuffix IS NULL))"
InsertCommand="INSERT INTO [Users] ([Username], [Password], [Memberlevel], [Stables], [PrefixSuffix]) VALUES (@Username, @Password, @Memberlevel, @Stables, @PrefixSuffix)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT * FROM [Users]"
UpdateCommand="UPDATE [Users] SET [Password] = @Password, [Memberlevel] = @Memberlevel, [Stables] = @Stables, [PrefixSuffix] = @PrefixSuffix WHERE [Username] = @original_Username AND [Password] = @original_Password AND [Memberlevel] = @original_Memberlevel AND [Stables] = @original_Stables AND (([PrefixSuffix] = @original_PrefixSuffix) OR ([PrefixSuffix] IS NULL AND @original_PrefixSuffix IS NULL))">
<DeleteParameters>
<asp:parameter Name="original_Username" Type="String" />
<asp:parameter Name="original_Password" Type="String" />
<asp:parameter Name="original_Memberlevel" Type="String" />
<asp:parameter Name="original_Stables" Type="String" />
<asp:parameter Name="original_PrefixSuffix" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="Password" Type="String" />
<asp:parameter Name="Memberlevel" Type="String" />
<asp:parameter Name="Stables" Type="String" />
<asp:parameter Name="PrefixSuffix" Type="String" />
<asp:parameter Name="original_Username" Type="String" />
<asp:parameter Name="original_Password" Type="String" />
<asp:parameter Name="original_Memberlevel" Type="String" />
<asp:parameter Name="original_Stables" Type="String" />
<asp:parameter Name="original_PrefixSuffix" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="Username" Type="String" />
<asp:parameter Name="Password" Type="String" />
<asp:parameter Name="Memberlevel" Type="String" />
<asp:parameter Name="Stables" Type="String" />
<asp:parameter Name="PrefixSuffix" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:MHR %>"
SelectCommand="SELECT DISTINCT [Memberlevel] FROM [Users]">
</asp:SqlDataSource>
<br />

</asp:Content>

Any suggestions would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top