Respuesta: Almacenar en Base de Datos Dato al cargar pagina. Hola de nuevo, el código de insert lo tengo, pero lo que necesito ahora es el codigo para poder eliminar los datos de una tabla que se encuentra filtrada por un campo en concreto, el codigo que tengo es el siguiente:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="respenvio.aspx.cs" Inherits="clientes_respenvio" Title="Página sin título" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div align="center"
style="font-family: VERdana; font-size: medium; color: #333333">
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="UserId" DataSourceID="SqlDataSource1" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3"
CellSpacing="2" style="font-size: xx-small">
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<Columns>
<asp:CommandField ShowDeleteButton="True" />
<asp:BoundField DataField="UserId" HeaderText="UserId" ReadOnly="True"
SortExpression="UserId" />
<asp:BoundField DataField="Pedido" HeaderText="Pedido"
SortExpression="Pedido" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="codart" HeaderText="codart"
SortExpression="codart" />
<asp:BoundField DataField="nomarticulo" HeaderText="nomarticulo"
SortExpression="nomarticulo" />
<asp:BoundField DataField="cantidad" HeaderText="cantidad"
SortExpression="cantidad" />
<asp:BoundField DataField="precioudad" HeaderText="precioudad"
SortExpression="precioudad" />
<asp:BoundField DataField="tiva" HeaderText="tiva" SortExpression="tiva" />
<asp:BoundField DataField="iva" HeaderText="iva" ReadOnly="True"
SortExpression="iva" />
<asp:BoundField DataField="preciosiniva" HeaderText="preciosiniva"
ReadOnly="True" SortExpression="preciosiniva" />
<asp:BoundField DataField="subtotal" HeaderText="subtotal" ReadOnly="True"
SortExpression="subtotal" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
DeleteCommand="DELETE FROM [PedidoUsuario] WHERE [UserId] = @original_UserId"
InsertCommand="INSERT INTO [PedidoUsuario] ([UserId], [Pedido], [UserName], [codart], [nomarticulo], [cantidad], [precioudad], [tiva], [iva], [preciosiniva], [subtotal]) VALUES (@UserId, @Pedido, @UserName, @codart, @nomarticulo, @cantidad, @precioudad, @tiva, @iva, @preciosiniva, @subtotal)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT [UserId], [Pedido], [UserName], [codart], [nomarticulo], [cantidad], [precioudad], [tiva], [iva], [preciosiniva], [subtotal] FROM [PedidoUsuario] WHERE ([Pedido] = @Pedido)"
UpdateCommand="UPDATE [PedidoUsuario] SET [Pedido] = @Pedido, [UserName] = @UserName, [codart] = @codart, [nomarticulo] = @nomarticulo, [cantidad] = @cantidad, [precioudad] = @precioudad, [tiva] = @tiva, [iva] = @iva, [preciosiniva] = @preciosiniva, [subtotal] = @subtotal WHERE [UserId] = @original_UserId AND [Pedido] = @original_Pedido AND (([UserName] = @original_UserName) OR ([UserName] IS NULL AND @original_UserName IS NULL)) AND [codart] = @original_codart AND [nomarticulo] = @original_nomarticulo AND [cantidad] = @original_cantidad AND [precioudad] = @original_precioudad AND (([tiva] = @original_tiva) OR ([tiva] IS NULL AND @original_tiva IS NULL)) AND (([iva] = @original_iva) OR ([iva] IS NULL AND @original_iva IS NULL)) AND (([preciosiniva] = @original_preciosiniva) OR ([preciosiniva] IS NULL AND @original_preciosiniva IS NULL)) AND (([subtotal] = @original_subtotal) OR ([subtotal] IS NULL AND @original_subtotal IS NULL))">
<SelectParameters>
<asp:ControlParameter ControlID="ipLabel" Name="Pedido" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_UserId" Type="Object" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Pedido" Type="String" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="codart" Type="String" />
<asp:Parameter Name="nomarticulo" Type="String" />
<asp:Parameter Name="cantidad" Type="Decimal" />
<asp:Parameter Name="precioudad" Type="Decimal" />
<asp:Parameter Name="tiva" Type="Decimal" />
<asp:Parameter Name="iva" Type="Decimal" />
<asp:Parameter Name="preciosiniva" Type="Decimal" />
<asp:Parameter Name="subtotal" Type="Decimal" />
<asp:Parameter Name="original_UserId" Type="Object" />
<asp:Parameter Name="original_Pedido" Type="String" />
<asp:Parameter Name="original_UserName" Type="String" />
<asp:Parameter Name="original_codart" Type="String" />
<asp:Parameter Name="original_nomarticulo" Type="String" />
<asp:Parameter Name="original_cantidad" Type="Decimal" />
<asp:Parameter Name="original_precioudad" Type="Decimal" />
<asp:Parameter Name="original_tiva" Type="Decimal" />
<asp:Parameter Name="original_iva" Type="Decimal" />
<asp:Parameter Name="original_preciosiniva" Type="Decimal" />
<asp:Parameter Name="original_subtotal" Type="Decimal" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="UserId" Type="Object" />
<asp:Parameter Name="Pedido" Type="String" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="codart" Type="String" />
<asp:Parameter Name="nomarticulo" Type="String" />
<asp:Parameter Name="cantidad" Type="Decimal" />
<asp:Parameter Name="precioudad" Type="Decimal" />
<asp:Parameter Name="tiva" Type="Decimal" />
<asp:Parameter Name="iva" Type="Decimal" />
<asp:Parameter Name="preciosiniva" Type="Decimal" />
<asp:Parameter Name="subtotal" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
<br />
</div>
</asp:Content> |