| |||
| Edit, Update, Cancel + Gridview Alguien De Ustedes Tiene Un Ejemplo De Edicion De Registros Con El Gridview A Traves De Codigo? No Usando Los Famosos Controlsitos Sqldatasource O Programando En El Aspx Sino En El Code Behind A Codigo Puro, Se Los Agradeceria. |
| |||
| Re: Edit, Update, Cancel + Gridview Cita: bueno estuve viendo por las webs y deseo convertir una celda en un control alguien tiene idea?¿?¿
Código:
If e.CommandName = "Edit" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim customersGridView As GridView = CType(e.CommandSource, GridView)
Dim row As GridViewRow = customersGridView.Rows(index)
' MsgBox(CStr(row.Cells.Item(3).Controls(0).ToString()))
Dim txt As TextBox = CType(row.Controls.Item(4), TextBox)
' Session("t2") = CType(row.Cells(4).Controls(4), TextBox)
' Session("t3") = CType(row.Cells(6).Controls(6), TextBox)
' Session("t4") = CType(row.Cells(5).Controls(5), TextBox)
' wsUpdate.Credentials = System.Net.CredentialCache.DefaultCredentials
Dim cad As String
Try
'cad = (wsUpdate.Actualizar_DIARIOS(Session("Id_Empresa"), t1.Text, t2.Text, t3.Text, 0, 0, 0, 0, 0, 0, 0, 0, 0, t4.Text, 0, 0, "", 0, 0, ""))
GvdAsientos.EditIndex = -1
DSDiarios.Merge(ws.Get_Diarios(Session("Id_Empresa")))
GvdAsientos.DataSource = DSDiarios
Me.GvdAsientos.DataBind()
Me.tb_error.Text = cad
Catch ex As Exception
Response.Redirect("Wfrm_Error.aspx")
Session("error") = ex.Message
End Try
End If
|
| |||
| Re: Edit, Update, Cancel + Gridview una pregunta como convierto una celda en un objeto??¿ If e.CommandName = "Edit" Then Dim index As Integer = Convert.ToInt32(e.CommandArgument) Dim row As GridViewRow = GvdAsientos.Rows(index) Dim t1 As TextBox = CType(row.Cells.Item(3).Controls(0), TextBox) Dim t2 As TextBox = CType(row.Cells.Item(4).Controls(0), TextBox) Dim t3 As TextBox = CType(row.Cells.Item(6).Controls(0), TextBox) Dim t4 As TextBox = CType(row.Cells.Item(5).Controls(0), TextBox) End If alguien me ayuda? |
| |||
| BUENO, YA QUE ESTUVE BUSCANDO INFORMACION Y QUE NINGUN "TIGRE" ME AYUDO ACA LE ENVIO LA SOLUCIONCODE BEHIND
Código:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SqlDataSource1 = New SqlDataSource("Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True", "SELECT EmployeeID, LastName, FirstName FROM employees")
SqlDataSource1.DeleteCommand = "DELETE FROM Employees WHERE EmployeeID = @EmployeeID"
SqlDataSource1.DeleteParameters.Add(New Parameter("EmployeeID", TypeCode.Int32))
SqlDataSource1.InsertCommand = "INSERT INTO Employees (LastName, FirstName) VALUES (@LastName, @FirstName)"
SqlDataSource1.InsertParameters.Add(New Parameter("LastName", TypeCode.String))
SqlDataSource1.InsertParameters.Add(New Parameter("FirstName", TypeCode.String))
SqlDataSource1.UpdateCommand = "UPDATE Employees SET LastName = @LastName, FirstName = @FirstName WHERE EmployeeID = @EmployeeID"
SqlDataSource1.UpdateParameters.Add(New Parameter("LastName", TypeCode.String))
SqlDataSource1.UpdateParameters.Add(New Parameter("FirstName", TypeCode.String))
SqlDataSource1.UpdateParameters.Add(New Parameter("EmployeeID", TypeCode.Int32))
If Not Page.IsPostBack Then
EnlazarDatos()
End If
End Sub
Private Sub EnlazarDatos()
GridView1.DataSource = SqlDataSource1
GridView1.DataBind()
End Sub
Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
GridView1.EditIndex = -1
EnlazarDatos()
End Sub
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim fila As GridViewRow = GridView1.Rows(e.RowIndex)
If Not (fila Is Nothing) Then
SqlDataSource1.DeleteParameters("EmployeeID").DefaultValue = CType(fila.FindControl("Label3"), Label).Text
SqlDataSource1.Delete()
EnlazarDatos()
End If
End Sub
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
GridView1.EditIndex = e.NewEditIndex
EnlazarDatos()
End Sub
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim fila As GridViewRow = GridView1.Rows(e.RowIndex)
If Not (fila Is Nothing) Then
Dim lbl1 As New Label
' lbl1.Text = CType(fila.FindControl("Label1"), Label).Text
'lbl1.Text = CType(fila.FindControl("TextBox1"), TextBox).Text
SqlDataSource1.UpdateParameters("EmployeeID").DefaultValue = CType(fila.FindControl("TextBox3"), TextBox).Text
SqlDataSource1.UpdateParameters("LastName").DefaultValue = CType(fila.FindControl("TextBox1"), TextBox).Text
SqlDataSource1.UpdateParameters("FirstName").DefaultValue = CType(fila.FindControl("TextBox2"), TextBox).Text
SqlDataSource1.Update()
GridView1.EditIndex = -1
EnlazarDatos()
End If
End Sub
Protected Sub BTNAGREGAR_Click(ByVal sender As Object, ByVal e As System.EventArgs)
SqlDataSource1.InsertParameters("FirstName").DefaultValue = TextBox2.Text
SqlDataSource1.InsertParameters("LastName").DefaultValue = TextBox1.Text
SqlDataSource1.Insert()
EnlazarDatos()
End Sub
End Class
ARCHIVO ASPX, ESTOY USANDO AJAX, SCRIPT MANAGER Y UPDATEPANEL.
Código:
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<div style="text-align: center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width: 515px; height: 259px">
<tr>
<td style="width: 100px">
LASTANAME</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
<td style="width: 100px">
FIRSTNAME</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
<td style="width: 100px">
<asp:Button ID="BTNAGREGAR" runat="server" OnClick="BTNAGREGAR_Click" Text="Button" />
</td>
</tr>
<tr>
<td colspan="5">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" HeaderText="Operaciones" />
<asp:CommandField ShowDeleteButton="True" />
<asp:TemplateField HeaderText="CODIGO">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("EmployeeID") %>' ReadOnly="True"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("EmployeeID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="APELLIDOS">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NOMBRES">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
</body>
</html>
|
| |||
| Respuesta: Edit, Update, Cancel + Gridview hay un problema si lo vez del punto de vista tu modificas y actualizas , directamente al la tabla de la base de datos ... si hay una forma de generar una tabla temporal con un datasource y actualiza esta table o dataset podría contener todos los cambios en una datatable y al final colocar un boton guardar todoooo Dim dv as DataView Dim Table as DataTable dv = CType(SqlDataSource1.Select(DataSourceSelectArgume nts.Empty), DataView) Table = dv.Table() si alguien tiene una forma de tabla temporal en una grilla sin estar recorriendo la gridview completamente seria genial |
| |||
| Respuesta: Edit, Update, Cancel + Gridview http://www.microsoft.com/en-us/downl....aspx?id=23654 la base para que puedan ejecutar el ejemplo del colega ...ejecuten el srips de las carpetas despues de la instalacion |
Este tema le ha gustado a 2 personas (incluyéndote)