code Bihind Visual Web Developer - asp.net campo sql relacionado por control en formview
Publicado por Mike (5 intervenciones) el 28/01/2019 19:24:15
como obtener el campo en code bihind c# que esta relacionado en cada control de un formview en webform en asp.net
ejemplo :
webform.aspx.cs
webform.aspx
ejemplo :
webform.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
foreach (Control childc in childd.Controls)
{
if (childc is TextBox)
{
allTextBoxValues += ((TextBox)childc).Text + ",";
}
if (childc is Label)
{
allTextBoxValues += "this works";
Label myLabel = (Label)childc;
}
if (childc is CheckBox)
{
CheckBox myCheckBox = (CheckBox)childc;
}
}
webform.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="UsuarioID" DataSourceID="SqlDataSource1" OnItemInserted="FormView1_ItemInserted" OnItemInserting="FormView1_ItemInserting" OnItemUpdated="FormView1_ItemUpdated" OnItemUpdating="FormView1_ItemUpdating">
<EditItemTemplate>
UsuarioID:
<asp:Label ID="UsuarioIDLabel1" runat="server" Text='<%# Eval("UsuarioID") %>' />
<br />
Usuario:
<asp:TextBox ID="UsuarioTextBox" runat="server" Text='<%# Bind("Usuario") %>' />
<br />
Password:
<asp:TextBox ID="PasswordTextBox" runat="server" Text='<%# Bind("Password") %>' />
<br />
Utilerias:
<asp:CheckBox ID="UtileriasCheckBox" runat="server" Checked='<%# Bind("Utilerias") %>' />
<br />
Activo:
<asp:CheckBox ID="ActivoCheckBox" runat="server" Checked='<%# Bind("Activo") %>' />
<br />
Foto:
<asp:TextBox ID="FotoTextBox" runat="server" Text='<%# Bind("Foto") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Actualizar" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
</EditItemTemplate>
Valora esta pregunta
![Me gusta: Está pregunta es útil y esta clara Me gusta: Está pregunta es útil y esta clara](/img/img.png?11.51)
![NO me gusta: Está pregunta no esta clara o no es útil No me gusta: Está pregunta no esta clara o no es útil](/img/img.png?11.51)
0