ASP.NET - Editar gridview

 
Vista:
sin imagen de perfil

Editar gridview

Publicado por Gonzalo (5 intervenciones) el 27/12/2016 00:13:37
Hola,

PD:
Estoy empezando a programar sin saber

Tengo un datagridview que se conecta con la base de datos , ademas le agregue los botones de editar registro y eliminar.
Al poner consultar anda genial , pero cuando entro al modo edicion(update de registro) se me agranda todo el gridview (las columnas y las celdas).

Como puedo editar esto? que se vea igual al consultar y al entrar al modo de edicion?

Gracias.

Sin-titulo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 101
Plata
Ha mantenido su posición en ASP.NET (en relación al último mes)
Gráfica de ASP.NET

Editar gridview

Publicado por Cesar (39 intervenciones) el 27/12/2016 00:28:20
Tienes que fijar las propiedades itemstyle-width y controlstyle-width, de las columnas de tu grid.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Editar gridview

Publicado por Gonzalo (5 intervenciones) el 27/12/2016 01:50:59
No lo encuentro, estoy usando visual studio 2015
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Editar gridview

Publicado por Gonzalo (5 intervenciones) el 27/12/2016 03:29:57
Agrego el codigo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 
 
 
   <form id="form1" runat="server">
        <table style="width: 100%;">
            <tr>
                <td style="width: 309px">&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td style="height: 37px; width: 309px;">Documento / Rut</td>
                <td style="height: 37px">
 
                    <asp:TextBox ID="txtdocumento" runat="server" Width="229px"></asp:TextBox>
 
                </td>
                <td style="height: 37px"></td>
            </tr>
            <tr>
                <td colspan="3">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID_Cliente" DataSourceID="SqlDataSource1" Width="100px">
                        <Columns>
                            <asp:BoundField DataField="ID_Cliente" ItemStyle-Width="50px" HeaderText="ID_Cliente" InsertVisible="False" ReadOnly="True" SortExpression="ID_Cliente">
                            <ItemStyle Width="128px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Nombre" ItemStyle-Width="50px" HeaderText="Nombre" SortExpression="Nombre">
                            <ItemStyle Width="128px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Apellido" HeaderText="Apellido" SortExpression="Apellido">
                            <ItemStyle Width="128px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="DocumentoRut" HeaderText="DocumentoRut" SortExpression="DocumentoRut">
                            <ItemStyle Width="128px" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Direccion" SortExpression="Direccion">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Direccion") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Direccion") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle Width="128px" />
                            </asp:TemplateField>
                            <asp:TemplateField ShowHeader="False">
                                <EditItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Actualizar"></asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancelar"></asp:LinkButton>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Editar"></asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle Width="128px" />
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SISLIVEConnectionString2SERVIDORWEB %>" DeleteCommand="DELETE FROM [Clientes] WHERE [ID_Cliente] = @ID_Cliente" InsertCommand="INSERT INTO [Clientes] ([Nombre], [Apellido], [DocumentoRut], [Direccion]) VALUES (@Nombre, @Apellido, @DocumentoRut, @Direccion)" SelectCommand="SELECT * FROM [Clientes] WHERE ([DocumentoRut] = @DocumentoRut)" UpdateCommand="UPDATE [Clientes] SET [Nombre] = @Nombre, [Apellido] = @Apellido, [DocumentoRut] = @DocumentoRut, [Direccion] = @Direccion WHERE [ID_Cliente] = @ID_Cliente">
                        <DeleteParameters>
                            <asp:Parameter Name="ID_Cliente" Type="Int32" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="Nombre" Type="String" />
                            <asp:Parameter Name="Apellido" Type="String"  />
                            <asp:Parameter Name="DocumentoRut" Type="String" />
                            <asp:Parameter Name="Direccion" Type="String" />
                        </InsertParameters>
                        <SelectParameters>
                            <asp:ControlParameter ControlID="txtdocumento" Name="DocumentoRut" PropertyName="Text" Type="String" />
                        </SelectParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="Nombre" Type="String" />
                            <asp:Parameter Name="Apellido" Type="String" />
                            <asp:Parameter Name="DocumentoRut" Type="String" />
                            <asp:Parameter Name="Direccion" Type="String" />
                            <asp:Parameter Name="ID_Cliente" Type="Int32" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </td>
            </tr>
        </table>
    </form>
 
</asp:Content>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar