teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの1行の記載を短くしました。

2019/12/22 19:16

投稿

Ecarlat
Ecarlat

スコア6

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 font-size="12pt" ID="GridView1" runat="server" DataKeyNames="Report_Id" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowSorting="True" CellPadding="3" ForeColor="Black" GridLines="Vertical" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px">
26
- <Columns>
27
- <asp:CommandField ShowSelectButton="True" ButtonType="Button" />
28
- <asp:HyperLinkField DataNavigateUrlFields="File_Name" DataNavigateUrlFormatString="/Report_Strage/{0}" DataTextField="Visit_Date" DataTextFormatString="{0:yyyy/MM/dd}" HeaderText="面談日" SortExpression="Visit_Date">
29
- <HeaderStyle HorizontalAlign="Center" />
30
- <ItemStyle Width="100px" HorizontalAlign="Center" />
31
- </asp:HyperLinkField>
32
- <asp:TemplateField HeaderText="顧客名" SortExpression="Customer_NameEng">
33
- <ItemTemplate>
34
- <asp:Label id="Label1" runat="server" Text='<%# Bind("Customer_NameEng") %>'></asp:Label>
35
- <br />
36
- <asp:Label id="Label2" runat="server" Text='<%# Bind("Customer_NameLoc") %>'></asp:Label>
37
- </ItemTemplate>
38
- <HeaderStyle HorizontalAlign="Center" />
39
- <ItemStyle Width="250px" />
40
- </asp:TemplateField>
41
- <asp:BoundField DataField="Customer_Country" HeaderText="所在国" SortExpression="Customer_Country">
42
- <HeaderStyle HorizontalAlign="Center" />
43
- <ItemStyle Width="100px" />
44
- </asp:BoundField>
45
- <asp:BoundField DataField="Supply_Product" HeaderText="供給製品" SortExpression="Supply_Product">
46
- <HeaderStyle HorizontalAlign="Center" />
47
- <ItemStyle Width="150px" />
48
- </asp:BoundField>
49
- <asp:BoundField DataField="Apprication" HeaderText="使用用途" SortExpression="Apprication">
50
- <HeaderStyle HorizontalAlign="Center" />
51
- <ItemStyle Width="300px" />
52
- </asp:BoundField>
53
- <asp:BoundField DataField="Reporter_Name" HeaderText="報告者" SortExpression="Reporter_Name">
54
- <HeaderStyle HorizontalAlign="Center" />
55
- <ItemStyle Width="100px" />
56
- </asp:BoundField>
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
- <EmptyDataTemplate>
81
+  <EmptyDataTemplate>
82
+   <asp:Label
83
+    id="Label4"
84
+    runat="server"
65
- <asp:Label id="Label4" runat="server" ForeColor="Red" Text="該当するデータがありません。&lt;br&gt;抽出条件を指定してから「検索」ボタンをクリックしてください。"></asp:Label>
85
+    Text="該当するデータがありません。&lt;br&gt;抽出条件を指定してから「検索」ボタンをクリックしてください。">
86
+   </asp:Label>
66
- </EmptyDataTemplate>
87
+  </EmptyDataTemplate>
67
- </asp:GridView>
88
+ </asp:GridView>
68
89
 
69
- &nbsp;<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="200px" AutoGenerateRows="False" CellPadding="4" DataKeyNames="Report_Id" DataSourceID="SqlDataSource1" DefaultMode="Insert" ForeColor="#333333" GridLines="None" AllowPaging="True">
70
- <Fields>
71
- <asp:BoundField DataField="Reporter_Name" HeaderText="報告者" SortExpression="Reporter_Name" />
72
- <asp:BoundField DataField="Reporter_Section" HeaderText="報告部署" SortExpression="Reporter_Section" />
73
- <asp:BoundField DataField="Visit_Year" HeaderText="Visit_Year" SortExpression="Visit_Year" />
74
- <asp:BoundField DataField="Visit_Date" HeaderText="訪問日" SortExpression="Visit_Date" />
75
- <asp:BoundField DataField="Customer_NameLoc" HeaderText="顧客名" SortExpression="Customer_NameLoc" />
76
- <asp:BoundField DataField="Customer_NameEng" HeaderText="顧客名(英語)" SortExpression="Customer_NameEng" />
77
- <asp:BoundField DataField="Customer_Country" HeaderText="所在国" SortExpression="Customer_Country" />
78
- <asp:BoundField DataField="Supply_Product" HeaderText="供給製品" SortExpression="Supply_Product" />
79
- <asp:BoundField DataField="Apprication" HeaderText="使用用途" SortExpression="Apprication" />
80
- <asp:BoundField DataField="File_Name" HeaderText="報告書ファイル名" SortExpression="File_Name" />
81
- <asp:CommandField ButtonType="Button" ShowInsertButton="True" ShowDeleteButton="True" ShowEditButton="True" />
82
- </Fields>
83
- </asp:DetailsView>
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
- &nbsp;<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
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], [Customer_NameLoc], [Customer_NameEng], [Customer_Country], [Supply_Product], [Apprication], [File_Name]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
88
-  SelectCommand="SELECT * FROM [Tbl_Data_Report] WHERE (([Visit_Year] LIKE '%' + ? + '%') AND ([Reporter_Name] LIKE '%' + ? + '%') AND ([Customer_Country] LIKE '%' + ? + '%') AND ([Reporter_Section] LIKE '%' + ? + '%') AND ([Customer_NameEng] LIKE '%' + ? + '%') AND ([Apprication] LIKE '%' + ? + '%') AND ([Supply_Product] LIKE '%' + ? + '%')) ORDER BY [Visit_Date] DESC, [Customer_NameEng]"
89
-  UpdateCommand="UPDATE [Tbl_Data_Report] SET [Reporter_Name] = ?, [Reporter_Section] = ?, [Visit_Year] = ?, [Customer_NameLoc] = ?, [Customer_NameEng] = ?, [Customer_Country] = ?, [Supply_Product] = ?, [Apprication] = ?, [File_Name] = ? WHERE [Report_Id] = ?">
90
- <DeleteParameters>
91
- <asp:Parameter Name="Report_Id" Type="Int32" />
92
- </DeleteParameters>
93
- <InsertParameters>
94
- <asp:Parameter Name="Report_Id" Type="Int32" />
95
- <asp:Parameter Name="Reporter_Name" Type="String" />
96
- <asp:Parameter Name="Reporter_Section" Type="String" />
97
- <asp:Parameter Name="Visit_Year" Type="String" />
98
- <asp:Parameter Name="Customer_NameLoc" Type="String" />
99
- <asp:Parameter Name="Customer_NameEng" Type="String" />
100
- <asp:Parameter Name="Customer_Country" Type="String" />
101
- <asp:Parameter Name="Supply_Product" Type="String" />
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
- </asp:Content>
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
  ```