Bonjours, il me manque une partie pour que mon code fonctionne et je ne trouve pas...
Voilà j'ai fait un Gridview avec dans le FooterTemplate un bouton pour insérer.
Voici mon code :
Et voici mon DataSource :
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
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 <asp:GridView ID="GV_Annonceur" runat="server" AutoGenerateColumns="False" DataKeyNames="no_categorie" DataSourceID="SqlMAJAnnonceur" ShowFooter="True" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Horizontal" style="margin-right: 0px"> <Columns> <asp:CommandField CancelText="Annuler" EditText="Éditer" ShowEditButton="True" UpdateText="Modifier" /> <asp:TemplateField HeaderText="#" InsertVisible="False" SortExpression="no_categorie"> <EditItemTemplate> <asp:Label ID="Label" runat="server" Text='<%# Eval("no_categorie") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("no_categorie") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:Button ID="AddProduct" runat="server" CommandName="Insert" Text="+" /> </FooterTemplate> <HeaderStyle HorizontalAlign="Center" /> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="Nom" SortExpression="nom_categorie"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("nom_categorie") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("nom_categorie") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox ID="NewName" runat="server"></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Description" SortExpression="description_categorie"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("description_categorie") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Bind("description_categorie") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox ID="NewDescription" runat="server"></asp:TextBox> </FooterTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="#009933" ForeColor="#333333" /> <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" /> <RowStyle BackColor="White" ForeColor="#333333" /> <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#F7F7F7" /> <SortedAscendingHeaderStyle BackColor="#487575" /> <SortedDescendingCellStyle BackColor="#E5E5E5" /> <SortedDescendingHeaderStyle BackColor="#275353" /> </asp:GridView>
Qu'est qui me manque?
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 <asp:SqlDataSource ID="SqlMAJAnnonceur" runat="server" ConnectionString="<%$ ConnectionStrings:ANNONCEURConnectionString %>" SelectCommand="SELECT * FROM [CATEGORIE]" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [CATEGORIE] WHERE [no_categorie] = @original_no_categorie AND [nom_categorie] = @original_nom_categorie AND (([description_categorie] = @original_description_categorie) OR ([description_categorie] IS NULL AND @original_description_categorie IS NULL))" InsertCommand="INSERT INTO [CATEGORIE] ([nom_categorie], [description_categorie]) VALUES (@nom_categorie, @description_categorie)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [CATEGORIE] SET [nom_categorie] = @nom_categorie, [description_categorie] = @description_categorie WHERE [no_categorie] = @original_no_categorie AND [nom_categorie] = @original_nom_categorie AND (([description_categorie] = @original_description_categorie) OR ([description_categorie] IS NULL AND @original_description_categorie IS NULL))"> <DeleteParameters> <asp:Parameter Name="original_no_categorie" Type="Int32" /> <asp:Parameter Name="original_nom_categorie" Type="String" /> <asp:Parameter Name="original_description_categorie" Type="String" /> </DeleteParameters> <InsertParameters> <asp:Parameter Name="nom_categorie" Type="String" /> <asp:Parameter Name="description_categorie" Type="String" /> </InsertParameters> <UpdateParameters> <asp:Parameter Name="nom_categorie" Type="String" /> <asp:Parameter Name="description_categorie" Type="String" /> <asp:Parameter Name="original_no_categorie" Type="Int32" /> <asp:Parameter Name="original_nom_categorie" Type="String" /> <asp:Parameter Name="original_description_categorie" Type="String" /> </UpdateParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
MErci d'avance!!!
Partager