[C#]Comment accéder à un champ dans un FormView ?
bonjour
J'essaye d'accèder à un champs qui est dans un formview :
Code:
1 2 3 4
| public void FormView5_DataBound(Object sender, EventArgs e)
{
string test = FormView5.HeaderRow.FindControl("TextBox1").ToString();
} |
mais j'ai toujours une erreur :
Citation:
La référence d'objet n'est pas définie à une instance d'un objet.
Si qqn a une idée ? Merci bcp
Pour la création du Formview :
Code:
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
| <asp:FormView ID="FormView5" runat="server" DataKeyNames="IDFlux" DataSourceID="SqlDataFlux">
<EditItemTemplate>
IDFlux:
<asp:Label ID="IDFluxLabel1" runat="server" Text='<%# Eval("IDFlux") %>'></asp:Label><br />
Nom:
<asp:TextBox ID="NomTextBox" runat="server" Text='<%# Bind("Nom") %>'></asp:TextBox><br />
Description:
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
Nom:
<asp:TextBox ID="NomTextBox" runat="server" Text='<%# Bind("Nom") %>'>
</asp:TextBox><br />
Description:
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
IDFlux:
<asp:Label ID="IDFluxLabel" runat="server" Text='<%# Eval("IDFlux") %>'></asp:Label><br />
Nom:
<asp:Label ID="NomLabel" runat="server" Text='<%# Bind("Nom") %>'></asp:Label><br />
Description:
<asp:Label ID="DescriptionLabel" runat="server" Text='<%# Bind("Description") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
Text="New"></asp:LinkButton>
</ItemTemplate>
</asp:FormView> |