Mensaje dentro de Acceso y trabajo con datos

Responder 
#1 - 06/10/2010 21:23:47 Reporta abuso | Link Permanente
Pituko
Fecha de registro: 06/10/2010
0 post en este tema
1 post en acceso y trabajo con datos
1 post en todos los foros
Problema actualizado registro en Datalist

Responder Citar
Buenas a todos:
Tengo un problema con el componente datalist. Hasta ayer funcionaba correctamente y hoy lo que me hace es que cuando le doy actualizar a una de las filas me coge los valores del último registro. Por qué pasa esto cuando el mismo proceso para actualizar lo tengo en otras aplicaciones y funcionan correctamente? les pego el código del datalist y del update
Gracias de antemano.

Datalist:
<asp:DataList ID="dtl_prices" runat="server" Width="100%" RepeatDirection="Vertical">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" style="width:90px">PERIOD</td><td align="center" style="width:90px">FROM</td><td align="center" style="width:90px">TO</td><td align="center" style="width:90px">1 WEEK</td><td align="center" style="width:90px">2 WEEKS</td><td align="center" style="width:90px">NIGHT</td><td align="center" style="width:90px">STAY</td><td align="center" style="width:90px">Options</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" style="width:90px">

<asp:HiddenField ID="hf_id" Value='<%# DataBinder.Eval(Container.DataItem, "id_payment") %>' runat="server" />
<asp:DropDownList ID="ddl_period_edit" runat="server">
</asp:DropDownList>
</td><td align="center" style="width:90px">
<asp:TextBox ID="txbitem_from" BorderWidth="1px" Width="75px" Text='<%# DataBinder.Eval(Container.DataItem, "datefrom_payment", "{0:dd-MM-yyyy}") %>' runat="server"></asp:TextBox></td><td align="center" style="width:90px">
<asp:TextBox ID="txbitem_to" BorderWidth="1px" Width="75px" Text='<%# DataBinder.Eval(Container.DataItem, "dateto_payment", "{0:dd-MM-yyyy}") %>' runat="server"></asp:TextBox></td><td align="center" style="width:90px"><asp:TextBox ID="txbitem_weekone" Width="50px" BorderWidth="1px" Text='<%# DataBinder.Eval(Container.DataItem, "weekone_payment", "{0:##,##.00}") %>' runat="server"></asp:TextBox></td><td align="center" style="width:90px"><asp:TextBox ID="txbitem_weektwo" Width="50px" BorderWidth="1px" Text='<%# DataBinder.Eval(Container.DataItem, "weektwo_payment", "{0:##,##.00}") %>' runat="server"></asp:TextBox></td><td align="center" style="width:90px"><asp:TextBox ID="txbitem_night" Width="50px" BorderWidth="1px" Text='<%# DataBinder.Eval(Container.DataItem, "night_payment", "{0:##,##.00}") %>' runat="server"></asp:TextBox></td><td align="center" style="width:90px">
<asp:DropDownList ID="ddl_stay" runat="server">
</asp:DropDownList>
</td><td align="center" style="width:93px">
<asp:Button ID="bt_update" runat="server" OnClick="update_property_Click" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "id_payment")%>' BorderWidth="1px" Text="Up." /> <asp:Button
ID="bt_delete" BorderWidth="1px" OnClick="delete_property_Click" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "id_payment")%>' OnClientClick="javascript:return confirm('Are you sure!!!\nYou want to delete the record permanently?');" runat="server" Text="Del." /></td>
</tr>
</table>
<cc1:CalendarExtender ID="calext_from" TargetControlID="txbitem_from" Format="dd-MM-yyyy" runat="server">
</cc1:CalendarExtender>
<cc1:CalendarExtender ID="calext_to" TargetControlID="txbitem_to" Format="dd-MM-yyyy" runat="server">
</cc1:CalendarExtender>
</ItemTemplate>
</asp:DataList>

Update procedure:

Sub update_property_Click(ByVal Sender As Object, ByVal e As System.EventArgs)
Dim usuario As String = CType(Session.Item("usuario"), String)
If Page.IsPostBack Then
Dim idpayment As Integer = ((CType(Sender, Button)).CommandArgument)
Dim item As DataListItem

'Dim i As Integer
For Each item In dtl_prices.Items

Dim txbweekone As TextBox = CType(item.FindControl("txbitem_weekone"), TextBox)
Dim txbweektwo As TextBox = CType(item.FindControl("txbitem_weektwo"), TextBox)
Dim txbnight As TextBox = CType(item.FindControl("txbitem_night"), TextBox)
Dim txbfrom As TextBox = CType(item.FindControl("txbitem_from"), TextBox)
Dim txbto As TextBox = CType(item.FindControl("txbitem_to"), TextBox)
Dim ddlperiod As DropDownList = CType(item.FindControl("ddl_period_edit"), DropDownList)
Dim ddlstay As DropDownList = CType(item.FindControl("ddl_stay"), DropDownList)

Dim weekonetxt As String = txbweekone.Text
Dim weektwotxt As String = txbweektwo.Text
Dim weeknighttxt As String = txbnight.Text


weekonetxt = weekonetxt.Replace(".", "")
weekonetxt = weekonetxt.Replace(",", ".")
weektwotxt = weektwotxt.Replace(".", "")
weektwotxt = weektwotxt.Replace(",", ".")
weeknighttxt = weeknighttxt.Replace(".", "")
weeknighttxt = weeknighttxt.Replace(",", ".")




Dim con As SqlConnection = New SqlConnection(CadenaConexion())
Dim sel As String

sel = "UPDATE PAYMENT SET period_payment='" & ddlperiod.SelectedValue & "', datefrom_payment='" & CType(txbfrom.Text, Date).ToString("yyyy-MM-dd") & "', dateto_payment='" & CType(txbto.Text, Date).ToString("yyyy-MM-dd") & "', night_payment ='" & weeknighttxt & "', stay_payment ='" & ddlstay.SelectedValue & "', weekone_payment ='" & weekonetxt & "', weektwo_payment ='" & weektwotxt & "' WHERE id_payment=" & idpayment

Dim cmd As New SqlCommand(sel, con)
Try
con.Open()
cmd.ExecuteNonQuery()
' Dim i As Integer = CInt(cmd.ExecuteScalar())
con.Close()
lb_notification.Text = " Updated Correctly " & sel & " " & idpayment & " " & ddlperiod.SelectedValue & " " & ddlstay.Text
logs.logs("update prices " & ddl_reference.SelectedValue, usuario)

Catch ex As Exception
senderror(usuario, "edit.aspx (owner)", ex.Message)
lb_notification.Text = "Error: " & ex.Message
End Try

Next

End If
Mostrargridview(ddl_reference.SelectedValue)
End Sub
Volver arriba