Bonjour,

Quelqu'un pourrait-il m'expliquer pourquoi lorsque j'insère un contrôle <asp:table> dans l'<InsertItemTemplate> d'un formulaire <asp:FormView>, je n'arrive pas à récupérer les valeurs de mes textbox pour les insérer dans ma table, par contre lorsque je fais un tableau html dans ce même <InsertItemTemplate> de mon formulaire, les données sont bien récupérées.

Code qui marche pas :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="True"
    CodeFile="Insertion.aspx.cs" Inherits="Admin_Insertion_User_Insertion" Title="Insertion Utilisateur" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="Server">
    <asp:SqlDataSource ID="Insert_user" runat="server" ConnectionString="<%$ ConnectionStrings:test %>"
        InsertCommand="INSERT INTO [Utilisateurs] (NomSociete) VALUES (@NomSociete)">
        <InsertParameters>
            <asp:Parameter Name="NomSociete" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <div align="center">
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="Id_User" DataSourceID="Insert_user"
            DefaultMode="Insert" OnItemInserted="ValiderInsertion">
            <InsertItemTemplate>
                <asp:Table runat="server" ID="Table1">
                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%#Bind("NomSociete") %>' BackColor="White"
                                Rows="2" MaxLength="255" Width="350px" TextMode="MultiLine" EnableTheming="false" ></asp:TextBox>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="true" CommandName="Insert"
                                Text="Insérer"></asp:LinkButton>
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
            </InsertItemTemplate>
        </asp:FormView>
    </div>
</asp:Content>

Code qui marche :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="True"
    CodeFile="Insertion.aspx.cs" Inherits="Admin_Insertion_User_Insertion" Title="Insertion Utilisateur" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="Server">
    <asp:SqlDataSource ID="Insert_user" runat="server" ConnectionString="<%$ ConnectionStrings:PNDConnectionString %>"
        InsertCommand="INSERT INTO [Utilisateurs] (NomSociete) VALUES (@NomSociete)">
        <InsertParameters>
            <asp:Parameter Name="NomSociete" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    <div align="center">
        <asp:FormView ID="FormView1" runat="server" DataKeyNames="Id_User" DataSourceID="Insert_user"
            DefaultMode="Insert" OnItemInserted="ValiderInsertion">
            <InsertItemTemplate>
                <Table>
                    <tr>
                        <td>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%#Bind("NomSociete") %>' BackColor="White"
                                Rows="2" MaxLength="255" Width="350px" TextMode="MultiLine" EnableTheming="false"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="true" CommandName="Insert"
                                Text="Insérer"></asp:LinkButton>
                        </td>
                    </tr>
                </Table>
            </InsertItemTemplate>
        </asp:FormView>
    </div>
</asp:Content>
Celà parle-t'il à quelqu'un ???