Hello,
J'ai un petit souci pour lié un un ObjectDataSource à un GridView. Voici le code :
Lorsque je sélectionne une ligne de GvContacts, le formview passe bien du mode insert au mode readonly mais il est vide
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132 <asp:GridView ID="GvContacts" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="nom,prenom,societe" DataSourceID="OdsContacts" OnSelectedIndexChanged="RafraichirContact" Width="100%"> <PagerSettings Mode="NextPreviousFirstLast" /> <Columns> <asp:CommandField ButtonType="Button" SelectText="Détail" ShowSelectButton="True"><ControlStyle Width="75px" /></asp:CommandField> <asp:BoundField DataField="titre" HeaderText="titre" SortExpression="titre" /> <asp:BoundField DataField="nom" HeaderText="nom" ReadOnly="True" SortExpression="nom" /> <asp:BoundField DataField="prenom" HeaderText="prenom" ReadOnly="True" SortExpression="prenom" /> <asp:BoundField DataField="societe" HeaderText="societe" ReadOnly="True" SortExpression="societe" Visible="False" /> <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" Visible="False" /> <asp:BoundField DataField="telephone" HeaderText="telephone" /> <asp:BoundField DataField="fax" HeaderText="fax" Visible="false" /> </Columns> <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" /> </asp:GridView> <asp:ObjectDataSource ID="OdsContacts" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDataBySociete" TypeName="AnnuaireTableAdapters.ContactsTableAdapter"> <SelectParameters> <asp:ControlParameter ControlID="DlListeSocietes" DefaultValue=" " Name="societe" PropertyName="SelectedValue" Type="String" /> </SelectParameters> </asp:ObjectDataSource> <asp:FormView ID="FvContact" runat="server" DataKeyNames="nom,prenom,societe" DataSourceID="OdsContact"> <EditItemTemplate> nom: <asp:Label ID="nomLabel1" runat="server" Text='<%# Eval("nom") %>'></asp:Label><br /> prenom: <asp:Label ID="prenomLabel1" runat="server" Text='<%# Eval("prenom") %>'></asp:Label><br /> societe: <asp:Label ID="societeLabel1" runat="server" Text='<%# Eval("societe") %>'></asp:Label><br /> email: <asp:TextBox ID="emailTextBox" runat="server" Text='<%# Bind("email") %>'> </asp:TextBox><br /> telephone: <asp:TextBox ID="telephoneTextBox" runat="server" Text='<%# Bind("telephone") %>'> </asp:TextBox><br /> fax: <asp:TextBox ID="faxTextBox" runat="server" Text='<%# Bind("fax") %>'> </asp:TextBox><br /> titre: <asp:TextBox ID="titreTextBox" runat="server" Text='<%# Bind("titre") %>'> </asp:TextBox><br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Mettre à jour"> </asp:LinkButton> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Annuler"> </asp:LinkButton> </EditItemTemplate> <InsertItemTemplate> nom: <asp:TextBox ID="nomTextBox" runat="server" Text='<%# Bind("nom") %>'> </asp:TextBox><br /> prenom: <asp:TextBox ID="prenomTextBox" runat="server" Text='<%# Bind("prenom") %>'> </asp:TextBox><br /> societe: <asp:TextBox ID="societeTextBox" runat="server" Text='<%# Bind("societe") %>'> </asp:TextBox><br /> email: <asp:TextBox ID="emailTextBox" runat="server" Text='<%# Bind("email") %>'> </asp:TextBox><br /> telephone: <asp:TextBox ID="telephoneTextBox" runat="server" Text='<%# Bind("telephone") %>'> </asp:TextBox><br /> fax: <asp:TextBox ID="faxTextBox" runat="server" Text='<%# Bind("fax") %>'> </asp:TextBox><br /> titre: <asp:TextBox ID="titreTextBox" runat="server" Text='<%# Bind("titre") %>'> </asp:TextBox><br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insérer"> </asp:LinkButton> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Annuler"> </asp:LinkButton> </InsertItemTemplate> <ItemTemplate> nom: <asp:Label ID="nomLabel" runat="server" Text='<%# Eval("nom") %>'></asp:Label><br /> prenom: <asp:Label ID="prenomLabel" runat="server" Text='<%# Eval("prenom") %>'></asp:Label><br /> societe: <asp:Label ID="societeLabel" runat="server" Text='<%# Eval("societe") %>'></asp:Label><br /> email: <asp:Label ID="emailLabel" runat="server" Text='<%# Bind("email") %>'></asp:Label><br /> telephone: <asp:Label ID="telephoneLabel" runat="server" Text='<%# Bind("telephone") %>'></asp:Label><br /> fax: <asp:Label ID="faxLabel" runat="server" Text='<%# Bind("fax") %>'></asp:Label><br /> titre: <asp:Label ID="titreLabel" runat="server" Text='<%# Bind("titre") %>'></asp:Label><br /> <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Modifier"></asp:LinkButton> <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Supprimer"></asp:LinkButton> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="Nouveau"></asp:LinkButton> </ItemTemplate> </asp:FormView> <asp:ObjectDataSource ID="OdsContact" runat="server" DeleteMethod="DeleteQuery" InsertMethod="InsertQuery" OldValuesParameterFormatString="original_{0}" SelectMethod="GetUnContact" TypeName="AnnuaireTableAdapters.ContactsTableAdapter" UpdateMethod="UpdateQuery" OnInserted="Rafraichir"> <DeleteParameters> <asp:Parameter Name="nom" Type="String" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="nom" Type="String" /> <asp:Parameter Name="prenom" Type="String" /> <asp:Parameter Name="email" Type="String" /> <asp:Parameter Name="telephone" Type="String" /> <asp:Parameter Name="titre" Type="String" /> <asp:Parameter Name="fax" Type="String" /> <asp:Parameter Name="Original_nom" Type="String" /> <asp:Parameter Name="Original_prenom" Type="String" /> <asp:Parameter Name="Original_societe" Type="String" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="GvContacts" Name="nom" PropertyName="SelectedValue" Type="String" DefaultValue=" " /> <asp:ControlParameter ControlID="GvContacts" DefaultValue=" " Name="prenom" PropertyName="SelectedValue" Type="String" /> <asp:ControlParameter ControlID="GvContacts" DefaultValue=" " Name="societe" PropertyName="SelectedValue" Type="String" /> </SelectParameters> <InsertParameters> <asp:Parameter Name="nom" Type="String" /> <asp:Parameter Name="prenom" Type="String" /> <asp:Parameter Name="societe" Type="String" /> <asp:Parameter Name="email" Type="String" /> <asp:Parameter Name="telephone" Type="String" /> <asp:Parameter Name="fax" Type="String" /> <asp:Parameter Name="titre" Type="String" /> </InsertParameters> </asp:ObjectDataSource>
Quid ?
Partager