質問編集履歴
1
コードの1行の記載を短くしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,122 +11,314 @@
|
|
11
11
|
この作業もWeb上でできるようにしたいと考えています。
|
12
12
|
|
13
13
|
そのため、上記のaspxファイルに、GridViewに連携させたDetailViewを追加し、データの追加、編集、削除などはDetailsViewで実施させようと思ったのですが、Webで開いても本来GridViewに表示するはずの元データ(絞込みする間には全データが表示するはず)自体が、表示しなくなってしまいました。
|
14
|
-
GridViewとDetailsViewは「Report_Id」をキーに連携
|
14
|
+
GridViewとDetailsViewは「Report_Id」をキーに連携のどこかに問題があるのだと思い調べては見たもののなかなか解決に至っておりません。
|
15
|
-
どこが悪さをしているのか、進展がありません。
|
16
15
|
|
17
|
-
確認すべき箇所、あるいはこのようなコードを記載する際の注意点
|
16
|
+
確認すべき箇所、あるいはこのようなコードを記載する際の注意点等ご教示いただけないでしょうか。
|
18
17
|
不足情報あれば、追記するようにします・
|
19
18
|
どうぞよろしくお願いします。
|
20
19
|
|
21
|
-
検索条件入力部分は文字数の関係で割愛しています。
|
22
|
-
そちらのコードが必要な場合はその旨コメントください。
|
23
|
-
|
24
20
|
```
|
25
|
-
<asp:GridView
|
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
|
-
<asp:BoundField DataField="Reporter_Section" HeaderText="報告部署" SortExpression="Reporter_Section">
|
58
|
-
<HeaderStyle HorizontalAlign="Center" />
|
59
|
-
<ItemStyle Width="150px" />
|
60
|
-
</asp:BoundField>
|
61
|
-
<asp:BoundField DataField="Report_Id" HeaderText="Report_Id" InsertVisible="False" ReadOnly="True" SortExpression="Report_Id" Visible="False" />
|
62
|
-
</Columns>
|
21
|
+
<asp:GridView
|
22
|
+
ID="GridView1"
|
23
|
+
runat="server"
|
24
|
+
DataKeyNames="Report_Id"
|
25
|
+
AutoGenerateColumns="False"
|
26
|
+
DataSourceID="SqlDataSource1">
|
27
|
+
<Columns>
|
28
|
+
<asp:CommandField
|
29
|
+
ShowSelectButton="True"
|
30
|
+
ButtonType="Button" />
|
31
|
+
<asp:HyperLinkField
|
32
|
+
DataNavigateUrlFields="File_Name"
|
33
|
+
DataNavigateUrlFormatString="/Report_Strage/{0}"
|
34
|
+
DataTextField="Visit_Date"
|
35
|
+
DataTextFormatString="{0:yyyy/MM/dd}"
|
36
|
+
HeaderText="面談日">
|
37
|
+
</asp:HyperLinkField>
|
38
|
+
<asp:TemplateField
|
39
|
+
HeaderText="顧客名">
|
40
|
+
<ItemTemplate>
|
41
|
+
<asp:Label
|
42
|
+
id="Label1"
|
43
|
+
runat="server"
|
44
|
+
Text='<%# Bind("Customer_NameEng") %>'>
|
45
|
+
</asp:Label><br />
|
46
|
+
<asp:Label
|
47
|
+
id="Label2"
|
48
|
+
runat="server"
|
49
|
+
Text='<%# Bind("Customer_NameLoc") %>'>
|
50
|
+
</asp:Label>
|
51
|
+
</ItemTemplate>
|
52
|
+
</asp:TemplateField>
|
63
53
|
|
54
|
+
<asp:BoundField
|
55
|
+
DataField="Customer_Country"
|
56
|
+
HeaderText="所在国">
|
57
|
+
</asp:BoundField>
|
58
|
+
<asp:BoundField
|
59
|
+
DataField="Supply_Product"
|
60
|
+
HeaderText="供給製品">
|
61
|
+
</asp:BoundField>
|
62
|
+
<asp:BoundField
|
63
|
+
DataField="Apprication"
|
64
|
+
HeaderText="使用用途">
|
65
|
+
</asp:BoundField>
|
66
|
+
<asp:BoundField
|
67
|
+
DataField="Reporter_Name"
|
68
|
+
HeaderText="報告者">
|
69
|
+
</asp:BoundField>
|
70
|
+
<asp:BoundField
|
71
|
+
DataField="Reporter_Section"
|
72
|
+
HeaderText="報告部署">
|
73
|
+
</asp:BoundField>
|
74
|
+
<asp:BoundField
|
75
|
+
DataField="Report_Id"
|
76
|
+
HeaderText="Report_Id"
|
77
|
+
InsertVisible="False"
|
78
|
+
ReadOnly="True"
|
79
|
+
Visible="False" />
|
80
|
+
</Columns>
|
64
|
-
|
81
|
+
<EmptyDataTemplate>
|
82
|
+
<asp:Label
|
83
|
+
id="Label4"
|
84
|
+
runat="server"
|
65
|
-
|
85
|
+
Text="該当するデータがありません。<br>抽出条件を指定してから「検索」ボタンをクリックしてください。">
|
86
|
+
</asp:Label>
|
66
|
-
|
87
|
+
</EmptyDataTemplate>
|
67
|
-
|
88
|
+
</asp:GridView>
|
68
89
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
90
|
+
<asp:DetailsView
|
91
|
+
ID="DetailsView1"
|
92
|
+
runat="server"
|
93
|
+
AutoGenerateRows="False"
|
94
|
+
DataKeyNames="Report_Id"
|
95
|
+
DataSourceID="SqlDataSource1"
|
96
|
+
DefaultMode="Insert">
|
97
|
+
<Fields>
|
98
|
+
<asp:BoundField
|
99
|
+
DataField="Reporter_Name"
|
100
|
+
HeaderText="報告者" />
|
101
|
+
<asp:BoundField
|
102
|
+
DataField="Reporter_Section"
|
103
|
+
HeaderText="報告部署" />
|
104
|
+
<asp:BoundField
|
105
|
+
DataField="Visit_Year"
|
106
|
+
HeaderText="Visit_Year" />
|
107
|
+
<asp:BoundField
|
108
|
+
DataField="Visit_Date"
|
109
|
+
HeaderText="訪問日" />
|
110
|
+
<asp:BoundField
|
111
|
+
DataField="Customer_NameLoc"
|
112
|
+
HeaderText="顧客名" />
|
113
|
+
<asp:BoundField
|
114
|
+
DataField="Customer_NameEng"
|
115
|
+
HeaderText="顧客名(英語)" />
|
116
|
+
<asp:BoundField
|
117
|
+
DataField="Customer_Country"
|
118
|
+
HeaderText="所在国" />
|
119
|
+
<asp:BoundField
|
120
|
+
DataField="Supply_Product"
|
121
|
+
HeaderText="供給製品" />
|
122
|
+
<asp:BoundField
|
123
|
+
DataField="Apprication"
|
124
|
+
HeaderText="使用用途" />
|
125
|
+
<asp:BoundField
|
126
|
+
DataField="File_Name"
|
127
|
+
HeaderText="報告書ファイル名" />
|
128
|
+
<asp:CommandField
|
129
|
+
ButtonType="Button"
|
130
|
+
ShowInsertButton="True"
|
131
|
+
ShowDeleteButton="True"
|
132
|
+
ShowEditButton="True" />
|
133
|
+
</Fields>
|
134
|
+
</asp:DetailsView>
|
84
135
|
|
136
|
+
<asp:SqlDataSource
|
137
|
+
ID="SqlDataSource1"
|
138
|
+
runat="server"
|
85
|
-
|
139
|
+
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
|
86
140
|
DeleteCommand="DELETE FROM [Tbl_Data_Report] WHERE [Report_Id] = ?"
|
87
|
-
InsertCommand="INSERT INTO [Tbl_Data_Report] ([Report_Id], [Reporter_Name], [Reporter_Section], [Visit_Year],
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
<asp:Parameter Name="Apprication" Type="String" />
|
103
|
-
<asp:Parameter Name="File_Name" Type="String" />
|
104
|
-
</InsertParameters>
|
105
|
-
<SelectParameters>
|
106
|
-
<asp:ControlParameter ControlID="DropDownList1" DefaultValue="%" Name="Visit_Year" PropertyName="SelectedValue" Type="String" />
|
107
|
-
<asp:ControlParameter ControlID="DropDownList2" DefaultValue="%" Name="Reporter_Name" PropertyName="SelectedValue" Type="String" />
|
108
|
-
<asp:ControlParameter ControlID="DropDownList3" DefaultValue="%" Name="Customer_Country" PropertyName="SelectedValue" Type="String" />
|
109
|
-
<asp:ControlParameter ControlID="DropDownList4" DefaultValue="%" Name="Reporter_Section" PropertyName="SelectedValue" Type="String" />
|
110
|
-
<asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="Customer_NameEng" PropertyName="Text" Type="String" />
|
111
|
-
<asp:ControlParameter ControlID="TextBox2" DefaultValue="%" Name="Apprication" PropertyName="Text" Type="String" />
|
112
|
-
<asp:ControlParameter ControlID="DropDownList5" DefaultValue="%" Name="Supply_Product" PropertyName="SelectedValue" Type="String" />
|
113
|
-
<asp:Parameter Name="Report_Id" Type="Int32" />
|
114
|
-
</SelectParameters>
|
115
|
-
<UpdateParameters>
|
116
|
-
<asp:Parameter Name="Reporter_Name" Type="String" />
|
117
|
-
<asp:Parameter Name="Reporter_Section" Type="String" />
|
118
|
-
<asp:Parameter Name="Visit_Year" Type="String" />
|
119
|
-
<asp:Parameter Name="Customer_NameLoc" Type="String" />
|
120
|
-
<asp:Parameter Name="Customer_NameEng" Type="String" />
|
121
|
-
<asp:Parameter Name="Customer_Country" Type="String" />
|
122
|
-
<asp:Parameter Name="Supply_Product" Type="String" />
|
123
|
-
<asp:Parameter Name="Apprication" Type="String" />
|
124
|
-
<asp:Parameter Name="File_Name" Type="String" />
|
125
|
-
<asp:Parameter Name="Report_Id" Type="Int32" />
|
126
|
-
</UpdateParameters>
|
127
|
-
</asp:SqlDataSource>
|
141
|
+
InsertCommand="INSERT INTO [Tbl_Data_Report] ([Report_Id], [Reporter_Name], [Reporter_Section], [Visit_Year],
|
142
|
+
[Customer_NameLoc], [Customer_NameEng], [Customer_Country], [Supply_Product], [Apprication], [File_Name])
|
143
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
|
144
|
+
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
|
145
|
+
SelectCommand="SELECT * FROM [Tbl_Data_Report]
|
146
|
+
WHERE (([Visit_Year] LIKE '%' + ? + '%') AND ([Reporter_Name] LIKE '%' + ? + '%') AND ([Customer_Country] LIKE '%' + ? + '%')
|
147
|
+
AND ([Reporter_Section] LIKE '%' + ? + '%') AND ([Customer_NameEng] LIKE '%' + ? + '%')
|
148
|
+
AND ([Apprication] LIKE '%' + ? + '%') AND ([Supply_Product] LIKE '%' + ? + '%'))
|
149
|
+
OR (([Visit_Year] LIKE '%' + ? + '%') AND ([Reporter_Name] LIKE '%' + ? + '%') AND ([Customer_Country] LIKE '%' + ? + '%')
|
150
|
+
AND ([Reporter_Section] LIKE '%' + ? + '%') AND ([Customer_NameLoc] LIKE '%' + ? + '%')
|
151
|
+
AND ([Apprication] LIKE '%' + ? + '%') AND ([Supply_Product] LIKE '%' + ? + '%'))
|
152
|
+
ORDER BY [Visit_Date] DESC, [Customer_NameEng]"
|
153
|
+
UpdateCommand="UPDATE [Tbl_Data_Report] SET [Reporter_Name] = ?, [Reporter_Section] = ?, [Visit_Year] = ?,
|
154
|
+
[Customer_NameLoc] = ?, [Customer_NameEng] = ?, [Customer_Country] = ?, [Supply_Product] = ?, [Apprication] = ?,
|
155
|
+
[File_Name] = ? WHERE [Report_Id] = ?">
|
128
156
|
|
157
|
+
<DeleteParameters>
|
158
|
+
<asp:Parameter
|
159
|
+
Name="Report_Id"
|
160
|
+
Type="Int32" />
|
129
|
-
</
|
161
|
+
</DeleteParameters>
|
130
162
|
|
163
|
+
<InsertParameters>
|
164
|
+
<asp:Parameter
|
165
|
+
Name="Report_Id"
|
166
|
+
Type="Int32" />
|
167
|
+
<asp:Parameter
|
168
|
+
Name="Reporter_Name"
|
169
|
+
Type="String" />
|
170
|
+
<asp:Parameter
|
171
|
+
Name="Reporter_Section"
|
172
|
+
Type="String" />
|
173
|
+
<asp:Parameter
|
174
|
+
Name="Visit_Year"
|
175
|
+
Type="String" />
|
176
|
+
<asp:Parameter
|
177
|
+
Name="Customer_NameLoc"
|
178
|
+
Type="String" />
|
179
|
+
<asp:Parameter
|
180
|
+
Name="Customer_NameEng"
|
181
|
+
Type="String" />
|
182
|
+
<asp:Parameter
|
183
|
+
Name="Customer_Country"
|
184
|
+
Type="String" />
|
185
|
+
<asp:Parameter
|
186
|
+
Name="Supply_Product"
|
187
|
+
Type="String" />
|
188
|
+
<asp:Parameter
|
189
|
+
Name="Apprication"
|
190
|
+
Type="String" />
|
191
|
+
<asp:Parameter
|
192
|
+
Name="File_Name"
|
193
|
+
Type="String" />
|
194
|
+
</InsertParameters>
|
131
195
|
|
196
|
+
<SelectParameters>
|
197
|
+
<asp:ControlParameter
|
198
|
+
ControlID="DropDownList1"
|
199
|
+
DefaultValue="%"
|
200
|
+
Name="Visit_Year"
|
201
|
+
PropertyName="SelectedValue"
|
202
|
+
Type="String" />
|
203
|
+
<asp:ControlParameter
|
204
|
+
ControlID="DropDownList2"
|
205
|
+
DefaultValue="%"
|
206
|
+
Name="Reporter_Name"
|
207
|
+
PropertyName="SelectedValue"
|
208
|
+
Type="String" />
|
209
|
+
<asp:ControlParameter
|
210
|
+
ControlID="DropDownList3"
|
211
|
+
DefaultValue="%"
|
212
|
+
Name="Customer_Country"
|
213
|
+
PropertyName="SelectedValue"
|
214
|
+
Type="String" />
|
215
|
+
<asp:ControlParameter
|
216
|
+
ControlID="DropDownList4"
|
217
|
+
DefaultValue="%"
|
218
|
+
Name="Reporter_Section"
|
219
|
+
PropertyName="SelectedValue"
|
220
|
+
Type="String" />
|
221
|
+
<asp:ControlParameter
|
222
|
+
ControlID="TextBox1"
|
223
|
+
DefaultValue="%"
|
224
|
+
Name="Customer_NameEng"
|
225
|
+
PropertyName="Text"
|
226
|
+
Type="String" />
|
227
|
+
<asp:ControlParameter
|
228
|
+
ControlID="TextBox2"
|
229
|
+
DefaultValue="%"
|
230
|
+
Name="Apprication"
|
231
|
+
PropertyName="Text"
|
232
|
+
Type="String" />
|
233
|
+
<asp:ControlParameter
|
234
|
+
ControlID="DropDownList5"
|
235
|
+
DefaultValue="%"
|
236
|
+
Name="Supply_Product"
|
237
|
+
PropertyName="SelectedValue"
|
238
|
+
Type="String" />
|
239
|
+
<asp:Parameter
|
240
|
+
Name="Report_Id"
|
241
|
+
Type="Int32" />
|
242
|
+
<asp:ControlParameter
|
243
|
+
ControlID="DropDownList1"
|
244
|
+
DefaultValue="%"
|
245
|
+
Name="Visit_Year"
|
246
|
+
PropertyName="SelectedValue"
|
247
|
+
Type="String" />
|
248
|
+
<asp:ControlParameter
|
249
|
+
ControlID="DropDownList2"
|
250
|
+
DefaultValue="%"
|
251
|
+
Name="Reporter_Name"
|
252
|
+
PropertyName="SelectedValue"
|
253
|
+
Type="String" />
|
254
|
+
<asp:ControlParameter
|
255
|
+
ontrolID="DropDownList3"
|
256
|
+
DefaultValue="%"
|
257
|
+
Name="Customer_Country"
|
258
|
+
PropertyName="SelectedValue"
|
259
|
+
Type="String" />
|
260
|
+
<asp:ControlParameter
|
261
|
+
ControlID="DropDownList4"
|
262
|
+
DefaultValue="%"
|
263
|
+
Name="Reporter_Section"
|
264
|
+
PropertyName="SelectedValue"
|
265
|
+
Type="String" />
|
266
|
+
<asp:ControlParameter
|
267
|
+
ControlID="TextBox1"
|
268
|
+
DefaultValue="%"
|
269
|
+
Name="Customer_NameLoc"
|
270
|
+
PropertyName="Text"
|
271
|
+
Type="String" />
|
272
|
+
<asp:ControlParameter
|
273
|
+
ControlID="TextBox2"
|
274
|
+
DefaultValue="%"
|
275
|
+
Name="Apprication"
|
276
|
+
PropertyName="Text"
|
277
|
+
Type="String" />
|
278
|
+
<asp:ControlParameter
|
279
|
+
ControlID="DropDownList5"
|
280
|
+
DefaultValue="%"
|
281
|
+
Name="Supply_Product"
|
282
|
+
PropertyName="SelectedValue"
|
283
|
+
Type="String" />
|
284
|
+
<asp:Parameter
|
285
|
+
Name="Report_Id"
|
286
|
+
Type="Int32" />
|
287
|
+
</SelectParameters>
|
288
|
+
|
289
|
+
<UpdateParameters>
|
290
|
+
<asp:Parameter
|
291
|
+
Name="Reporter_Name"
|
292
|
+
Type="String" />
|
293
|
+
<asp:Parameter
|
294
|
+
Name="Reporter_Section"
|
295
|
+
Type="String" />
|
296
|
+
<asp:Parameter
|
297
|
+
Name="Visit_Year"
|
298
|
+
Type="String" />
|
299
|
+
<asp:Parameter
|
300
|
+
Name="Customer_NameLoc"
|
301
|
+
Type="String" />
|
302
|
+
<asp:Parameter
|
303
|
+
Name="Customer_NameEng"
|
304
|
+
Type="String" />
|
305
|
+
<asp:Parameter
|
306
|
+
Name="Customer_Country"
|
307
|
+
Type="String" />
|
308
|
+
<asp:Parameter
|
309
|
+
Name="Supply_Product"
|
310
|
+
Type="String" />
|
311
|
+
<asp:Parameter
|
312
|
+
Name="Apprication"
|
313
|
+
Type="String" />
|
314
|
+
<asp:Parameter
|
315
|
+
Name="File_Name"
|
316
|
+
Type="String" />
|
317
|
+
<asp:Parameter
|
318
|
+
Name="Report_Id"
|
319
|
+
Type="Int32" />
|
320
|
+
</UpdateParameters>
|
321
|
+
</asp:SqlDataSource>
|
322
|
+
|
323
|
+
</asp:Content>
|
132
324
|
```
|