0% found this document useful (0 votes)
25 views

GV 1 Code 1

The document describes a form with fields for a user's personal identification number, first name, second name, first last name, and second last name. It includes validators to require entries and check data types. A grid view displays the data from a SQL database and allows editing, deleting, and selecting records.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

GV 1 Code 1

The document describes a form with fields for a user's personal identification number, first name, second name, first last name, and second last name. It includes validators to require entries and check data types. A grid view displays the data from a SQL database and allows editing, deleting, and selecting records.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

<table>

<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Cédula"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtPersonalId" MaxLength="12" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RFVTxtPersonalId" runat="server"


ControlToValidate="TxtPersonalId"
ErrorMessage="*" ForeColor="Red"
ToolTip="Este campo es requerido">
</asp:RequiredFieldValidator>

<asp:RegularExpressionValidator ID="REVTxtPersonalId" runat="server"


ControlToValidate="TxtPersonalId"
ErrorMessage="*" ForeColor="Red"
ToolTip="Este campo solo permite datos numericos"
ValidationExpression="[0-9]{0,12}">
</asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Primer Nombre"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtFirstName" MaxLength="50" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RFVTxtFirstName" runat="server"


ControlToValidate="TxtFirstName"
ErrorMessage="*" ForeColor="Red"
ToolTip="Este campo es requerido">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Segundo Nombre</td>
<td>
<asp:TextBox ID="TxtSecondName" MaxLength="50" runat="server"></asp:TextBox>

</td>
</tr>
<tr>
<td>
Primer Apellido<br />
</td>
<td>
<asp:TextBox ID="TxtFirstLastName" MaxLength="50" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RFVTxtFirstLastName" runat="server"


ControlToValidate="TxtFirstLastName"
ErrorMessage="*" ForeColor="Red"
ToolTip="Este campo es requerido">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Segundo Apellido<br />
</td>
<td>
<asp:TextBox ID="TxtSecondLastName" MaxLength="50"
runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="BtSave" runat="server" CommandName="Add" Text="Agregar"
onclick="BtSave_Click" />
</td>
</tr>
</table>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Id" DataSourceID="SqlDataSourceDemoASP" AllowPaging="True"
AllowSorting="True">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id"
Visible="false" SortExpression="Id"
ReadOnly="True" />

<asp:BoundField DataField="PersonalId" ControlStyle-Width="96%"


ItemStyle-HorizontalAlign="Right" ItemStyle-Width="150px"
HeaderText="Identificación Personal" SortExpression="PersonalId" />

<asp:BoundField DataField="FirstName" ItemStyle-Width="150px"


HeaderText="Primer Nombre" SortExpression="FirstName" />

<asp:BoundField DataField="SecondName" ItemStyle-Width="150px"


HeaderText="Segundo Nombre" SortExpression="SecondName" />

<asp:BoundField DataField="FirstLastName" ItemStyle-Width="150px"


HeaderText="Primer Apellido" SortExpression="FirstLastName" />

<asp:BoundField DataField="SecondLastName" ItemStyle-Width="150px"


HeaderText="Segundo Apellido" SortExpression="SecondLastName" />

<asp:CommandField ShowDeleteButton="True" DeleteText="Eliminar"


EditText="Editar" ShowEditButton="True"
CancelText="Cancelar" ShowSelectButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceDemoASP" runat="server"
ConnectionString="<%$ ConnectionStrings:DemoASPConnectionString %>"

SelectCommand="SELECT
[PersonalId],
[SecondName],
[FirstName],
[FirstLastName],
[SecondLastName],
[Id]
FROM [Person]"
ConflictDetection="CompareAllValues"

DeleteCommand="DELETE FROM [Person]


WHERE [Id] = @original_Id AND
[PersonalId] = @original_PersonalId AND
(([SecondName] = @original_SecondName) OR ([SecondName] IS NULL AND
@original_SecondName IS NULL)) AND
[FirstName] = @original_FirstName AND
[FirstLastName] = @original_FirstLastName AND
(([SecondLastName] = @original_SecondLastName) OR ([SecondLastName] IS
NULL AND
@original_SecondLastName IS NULL))"

InsertCommand="INSERT INTO [Person] ([PersonalId], [SecondName], [FirstName],


[FirstLastName], [SecondLastName])
VALUES (@PersonalId, @SecondName, @FirstName, @FirstLastName,
@SecondLastName)"
OldValuesParameterFormatString="original_{0}"

UpdateCommand="UPDATE [Person]
SET
[PersonalId] = @PersonalId,
[SecondName] = @SecondName,
[FirstName] = @FirstName,
[FirstLastName] = @FirstLastName,
[SecondLastName] = @SecondLastName
WHERE
[Id] = @original_Id AND
[PersonalId] = @original_PersonalId AND
(([SecondName] = @original_SecondName) OR ([SecondName] IS NULL AND
@original_SecondName IS NULL)) AND
[FirstName] = @original_FirstName AND
[FirstLastName] = @original_FirstLastName AND
(([SecondLastName] = @original_SecondLastName) OR ([SecondLastName] IS
NULL AND
@original_SecondLastName IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_PersonalId" Type="Int32" />
<asp:Parameter Name="original_SecondName" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_FirstLastName" Type="String" />
<asp:Parameter Name="original_SecondLastName" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="PersonalId" Type="Int32" />
<asp:Parameter Name="SecondName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="FirstLastName" Type="String" />
<asp:Parameter Name="SecondLastName" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="PersonalId" Type="Int32" />
<asp:Parameter Name="SecondName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="FirstLastName" Type="String" />
<asp:Parameter Name="SecondLastName" Type="String" />
<asp:Parameter Name="original_Id" Type="Int32" />
<asp:Parameter Name="original_PersonalId" Type="Int32" />
<asp:Parameter Name="original_SecondName" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_FirstLastName" Type="String" />
<asp:Parameter Name="original_SecondLastName" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>

You might also like