G
Guest
I setup a simple gridview as a utility just to do some updates, nothing fancy
just wanted easy UI to make updates. When I select ‘Edit’, I get the fields
I want to edit. I edit them and click ‘Update’, the page returns to its
original state (prior to clicking Edit) and no updates occur in the DB. What
am I missing? I included the html code below.
--
Thank-you,
Barbara Alderton
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="DBNameSource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT DISTINCT [DBName] FROM
[CNV_CODE_MAPPING]"></asp:SqlDataSource>
<asp:SqlDataSource ID="TableSource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT DISTINCT [TableName] FROM
[CNV_CODE_MAPPING] WHERE ([DBName] = @DBName)">
<SelectParameters>
<asp:ControlParameter ControlID="ddDataBases" Name="DBName"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="ForeignKeySource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT DISTINCT [ForeignKey] FROM
[CNV_CODE_MAPPING] WHERE (([DBName] = @DBName) AND ([TableName] =
@TableName))">
<SelectParameters>
<asp:ControlParameter ControlID="ddDataBases" Name="DBName"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddTables" Name="TableName"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<asp:SqlDataSource ID="DataGridSource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT [Mapping_UID], [DBName], [TableName],
[ForeignKey], [UIDOld], [ValueOld], [DescOld], [CreateDate], [DescNew],
[ValueNew], [UIDNew], [LastChangeDate] FROM [CNV_CODE_MAPPING] WHERE
(([DBName] = @DBName) AND ([TableName] = @TableName) AND ([ForeignKey] =
@ForeignKey))" OldValuesParameterFormatString="original_{0}"
DeleteCommand="DELETE FROM [CNV_CODE_MAPPING] WHERE [Mapping_UID] =
@original_Mapping_UID" InsertCommand="INSERT INTO [CNV_CODE_MAPPING]
([DBName], [TableName], [ForeignKey], [UIDOld], [ValueOld], [DescOld],
[CreateDate], [DescNew], [ValueNew], [UIDNew], [LastChangeDate]) VALUES
(@DBName, @TableName, @ForeignKey, @UIDOld, @ValueOld, @DescOld, @CreateDate,
@DescNew, @ValueNew, @UIDNew, @LastChangeDate)" UpdateCommand="UPDATE
[CNV_CODE_MAPPING] SET [DBName] = @DBName, [TableName] = @TableName,
[ForeignKey] = @ForeignKey, [UIDOld] = @UIDOld, [ValueOld] = @ValueOld,
[DescOld] = @DescOld, [CreateDate] = @CreateDate, [DescNew] = @DescNew,
[ValueNew] = @ValueNew, [UIDNew] = @UIDNew, [LastChangeDate] =
@LastChangeDate WHERE [Mapping_UID] = @original_Mapping_UID">
<SelectParameters>
<asp:ControlParameter ControlID="ddDataBases" Name="DBName"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddTables" Name="TableName"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddForeignKeys"
Name="ForeignKey" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<DeleteParameters>
<asparameter Name="original_Mapping_UID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="DBName" Type="String" />
<asparameter Name="TableName" Type="String" />
<asparameter Name="ForeignKey" Type="String" />
<asparameter Name="UIDOld" Type="Int32" />
<asparameter Name="ValueOld" Type="String" />
<asparameter Name="DescOld" Type="String" />
<asparameter Name="CreateDate" Type="DateTime" />
<asparameter Name="DescNew" Type="String" />
<asparameter Name="ValueNew" Type="String" />
<asparameter Name="UIDNew" Type="Int32" />
<asparameter Name="LastChangeDate" Type="DateTime" />
<asparameter Name="original_Mapping_UID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="DBName" Type="String" />
<asparameter Name="TableName" Type="String" />
<asparameter Name="ForeignKey" Type="String" />
<asparameter Name="UIDOld" Type="Int32" />
<asparameter Name="ValueOld" Type="String" />
<asparameter Name="DescOld" Type="String" />
<asparameter Name="CreateDate" Type="DateTime" />
<asparameter Name="DescNew" Type="String" />
<asparameter Name="ValueNew" Type="String" />
<asparameter Name="UIDNew" Type="Int32" />
<asparameter Name="LastChangeDate" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
<table style="width: 800px">
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 150px">
</td>
<td style="text-align: center; width: 490px">
<span style="font-family: Arial"><strong>Code Mapping
Tool</strong></span></td>
<td style="width: 150px">
</td>
</tr>
<tr>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 400px">
<tr>
<td style="width: 167px">
<asp:Label ID="Label1" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="DataBase Name:"
Width="120px"></asp:Label></td>
<td style="width: 200px">
<aspropDownList ID="ddDataBases"
runat="server" AutoPostBack="True" DataSourceID="DBNameSource"
DataTextField="DBName"
DataValueField="DBName">
</aspropDownList></td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 167px; height: 20px;">
<asp:Label ID="lblTblTag" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Table Name:"></asp:Label></td>
<td style="width: 200px; height: 20px;">
<aspropDownList ID="ddTables"
runat="server" AutoPostBack="True" DataSourceID="TableSource"
DataTextField="TableName"
DataValueField="TableName">
</aspropDownList></td>
<td style="width: 100px; height: 20px;">
</td>
</tr>
<tr>
<td style="width: 167px">
<asp:Label ID="Label2" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Foreign Key:"></asp:Label></td>
<td style="width: 200px">
<aspropDownList ID="ddForeignKeys"
runat="server" AutoPostBack="True" DataSourceID="ForeignKeySource"
DataTextField="ForeignKey"
DataValueField="ForeignKey">
</aspropDownList></td>
<td style="width: 100px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False"
BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellPadding="4"
CellSpacing="2" DataSourceID="DataGridSource"
ForeColor="Black">
<FooterStyle BackColor="#CCCCCC" />
<Columns>
<asp:BoundField
DataField="Mapping_UID" HeaderText="Mapping_UID" InsertVisible="False"
ReadOnly="True"
SortExpression="Mapping_UID" />
<asp:BoundField
DataField="TableName" HeaderText="Table Name" ReadOnly="True"
SortExpression="TableName" >
<FooterStyle Width="50px" />
</asp:BoundField>
<asp:BoundField
DataField="ForeignKey" HeaderText="Foreign Key" ReadOnly="True"
SortExpression="ForeignKey" />
<asp:BoundField DataField="UIDOld"
HeaderText="Old UID" ReadOnly="True" SortExpression="UIDOld" />
<asp:BoundField DataField="ValueOld"
HeaderText="Old Value" ReadOnly="True" SortExpression="ValueOld" />
<asp:BoundField DataField="DescOld"
HeaderText="Old Desc" ReadOnly="True" SortExpression="DescOld" />
<asp:BoundField
DataField="CreateDate" DataFormatString="{0:d}" HeaderText="Create Date"
HtmlEncode="False"
ReadOnly="True" SortExpression="CreateDate" />
<asp:BoundField DataField="UIDNew"
HeaderText="UIDNew" SortExpression="UIDNew" />
<asp:BoundField DataField="ValueNew"
HeaderText="New Value" SortExpression="ValueNew" />
<asp:BoundField DataField="DescNew"
HeaderText="New Desc" SortExpression="DescNew" />
<asp:BoundField
DataField="LastChangeDate" HeaderText="Last Change Date"
SortExpression="LastChangeDate" />
<asp:CommandField
ShowEditButton="True" />
</Columns>
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099"
Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC"
ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle BackColor="Black"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
ForeColor="White" />
</asp:GridView>
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
just wanted easy UI to make updates. When I select ‘Edit’, I get the fields
I want to edit. I edit them and click ‘Update’, the page returns to its
original state (prior to clicking Edit) and no updates occur in the DB. What
am I missing? I included the html code below.
--
Thank-you,
Barbara Alderton
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="DBNameSource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT DISTINCT [DBName] FROM
[CNV_CODE_MAPPING]"></asp:SqlDataSource>
<asp:SqlDataSource ID="TableSource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT DISTINCT [TableName] FROM
[CNV_CODE_MAPPING] WHERE ([DBName] = @DBName)">
<SelectParameters>
<asp:ControlParameter ControlID="ddDataBases" Name="DBName"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="ForeignKeySource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT DISTINCT [ForeignKey] FROM
[CNV_CODE_MAPPING] WHERE (([DBName] = @DBName) AND ([TableName] =
@TableName))">
<SelectParameters>
<asp:ControlParameter ControlID="ddDataBases" Name="DBName"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddTables" Name="TableName"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<asp:SqlDataSource ID="DataGridSource" runat="server"
ConnectionString="<%$ ConnectionStrings:CONV_ADMINConnectionString %>"
SelectCommand="SELECT [Mapping_UID], [DBName], [TableName],
[ForeignKey], [UIDOld], [ValueOld], [DescOld], [CreateDate], [DescNew],
[ValueNew], [UIDNew], [LastChangeDate] FROM [CNV_CODE_MAPPING] WHERE
(([DBName] = @DBName) AND ([TableName] = @TableName) AND ([ForeignKey] =
@ForeignKey))" OldValuesParameterFormatString="original_{0}"
DeleteCommand="DELETE FROM [CNV_CODE_MAPPING] WHERE [Mapping_UID] =
@original_Mapping_UID" InsertCommand="INSERT INTO [CNV_CODE_MAPPING]
([DBName], [TableName], [ForeignKey], [UIDOld], [ValueOld], [DescOld],
[CreateDate], [DescNew], [ValueNew], [UIDNew], [LastChangeDate]) VALUES
(@DBName, @TableName, @ForeignKey, @UIDOld, @ValueOld, @DescOld, @CreateDate,
@DescNew, @ValueNew, @UIDNew, @LastChangeDate)" UpdateCommand="UPDATE
[CNV_CODE_MAPPING] SET [DBName] = @DBName, [TableName] = @TableName,
[ForeignKey] = @ForeignKey, [UIDOld] = @UIDOld, [ValueOld] = @ValueOld,
[DescOld] = @DescOld, [CreateDate] = @CreateDate, [DescNew] = @DescNew,
[ValueNew] = @ValueNew, [UIDNew] = @UIDNew, [LastChangeDate] =
@LastChangeDate WHERE [Mapping_UID] = @original_Mapping_UID">
<SelectParameters>
<asp:ControlParameter ControlID="ddDataBases" Name="DBName"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddTables" Name="TableName"
PropertyName="SelectedValue"
Type="String" />
<asp:ControlParameter ControlID="ddForeignKeys"
Name="ForeignKey" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<DeleteParameters>
<asparameter Name="original_Mapping_UID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asparameter Name="DBName" Type="String" />
<asparameter Name="TableName" Type="String" />
<asparameter Name="ForeignKey" Type="String" />
<asparameter Name="UIDOld" Type="Int32" />
<asparameter Name="ValueOld" Type="String" />
<asparameter Name="DescOld" Type="String" />
<asparameter Name="CreateDate" Type="DateTime" />
<asparameter Name="DescNew" Type="String" />
<asparameter Name="ValueNew" Type="String" />
<asparameter Name="UIDNew" Type="Int32" />
<asparameter Name="LastChangeDate" Type="DateTime" />
<asparameter Name="original_Mapping_UID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asparameter Name="DBName" Type="String" />
<asparameter Name="TableName" Type="String" />
<asparameter Name="ForeignKey" Type="String" />
<asparameter Name="UIDOld" Type="Int32" />
<asparameter Name="ValueOld" Type="String" />
<asparameter Name="DescOld" Type="String" />
<asparameter Name="CreateDate" Type="DateTime" />
<asparameter Name="DescNew" Type="String" />
<asparameter Name="ValueNew" Type="String" />
<asparameter Name="UIDNew" Type="Int32" />
<asparameter Name="LastChangeDate" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
<table style="width: 800px">
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 150px">
</td>
<td style="text-align: center; width: 490px">
<span style="font-family: Arial"><strong>Code Mapping
Tool</strong></span></td>
<td style="width: 150px">
</td>
</tr>
<tr>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 400px">
<tr>
<td style="width: 167px">
<asp:Label ID="Label1" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="DataBase Name:"
Width="120px"></asp:Label></td>
<td style="width: 200px">
<aspropDownList ID="ddDataBases"
runat="server" AutoPostBack="True" DataSourceID="DBNameSource"
DataTextField="DBName"
DataValueField="DBName">
</aspropDownList></td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 167px; height: 20px;">
<asp:Label ID="lblTblTag" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Table Name:"></asp:Label></td>
<td style="width: 200px; height: 20px;">
<aspropDownList ID="ddTables"
runat="server" AutoPostBack="True" DataSourceID="TableSource"
DataTextField="TableName"
DataValueField="TableName">
</aspropDownList></td>
<td style="width: 100px; height: 20px;">
</td>
</tr>
<tr>
<td style="width: 167px">
<asp:Label ID="Label2" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Foreign Key:"></asp:Label></td>
<td style="width: 200px">
<aspropDownList ID="ddForeignKeys"
runat="server" AutoPostBack="True" DataSourceID="ForeignKeySource"
DataTextField="ForeignKey"
DataValueField="ForeignKey">
</aspropDownList></td>
<td style="width: 100px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False"
BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid"
BorderWidth="3px" CellPadding="4"
CellSpacing="2" DataSourceID="DataGridSource"
ForeColor="Black">
<FooterStyle BackColor="#CCCCCC" />
<Columns>
<asp:BoundField
DataField="Mapping_UID" HeaderText="Mapping_UID" InsertVisible="False"
ReadOnly="True"
SortExpression="Mapping_UID" />
<asp:BoundField
DataField="TableName" HeaderText="Table Name" ReadOnly="True"
SortExpression="TableName" >
<FooterStyle Width="50px" />
</asp:BoundField>
<asp:BoundField
DataField="ForeignKey" HeaderText="Foreign Key" ReadOnly="True"
SortExpression="ForeignKey" />
<asp:BoundField DataField="UIDOld"
HeaderText="Old UID" ReadOnly="True" SortExpression="UIDOld" />
<asp:BoundField DataField="ValueOld"
HeaderText="Old Value" ReadOnly="True" SortExpression="ValueOld" />
<asp:BoundField DataField="DescOld"
HeaderText="Old Desc" ReadOnly="True" SortExpression="DescOld" />
<asp:BoundField
DataField="CreateDate" DataFormatString="{0:d}" HeaderText="Create Date"
HtmlEncode="False"
ReadOnly="True" SortExpression="CreateDate" />
<asp:BoundField DataField="UIDNew"
HeaderText="UIDNew" SortExpression="UIDNew" />
<asp:BoundField DataField="ValueNew"
HeaderText="New Value" SortExpression="ValueNew" />
<asp:BoundField DataField="DescNew"
HeaderText="New Desc" SortExpression="DescNew" />
<asp:BoundField
DataField="LastChangeDate" HeaderText="Last Change Date"
SortExpression="LastChangeDate" />
<asp:CommandField
ShowEditButton="True" />
</Columns>
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099"
Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC"
ForeColor="Black" HorizontalAlign="Left" />
<HeaderStyle BackColor="Black"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
ForeColor="White" />
</asp:GridView>
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>