私のテキストボックスは1つの値を入力し、同じものを約8つ入力することになっています。誰もが理由を知っていますか?
<li class="item">
<asp:LinkButton ID="FeatureButton" runat="server">Feature</asp:LinkButton>
<asp:Panel ID="FeaturePanel" runat="server" CssClass="modalPopup"
Style="display:none">
<div class="PopupHeader">Add a Feature</div>
<asp:CheckBoxList ID="cbxAddFeature" runat="server"
DataSourceID="dsNewFeatures" DataTextField="FeatureTitle"
DataValueField="FeatureID"></asp:CheckBoxList>
New Feature:<asp:TextBox ID="txtFeature" runat="server"></asp:TextBox>
<asp:Label ID="FeatureError" runat="server" ></asp:Label>
<asp:Button ID="SubmitFeatures" runat="server" Text="Submit" />
<asp:Button ID="CancelSubmitFeatures" runat="server" Text="Cancel" />
</asp:Panel>
<asp:ModalPopupExtender ID="FeatureModal" runat="server"
BackgroundCssClass="modalBackground"
CancelControlID="CancelSubmitFeatures" DropShadow="True"
DynamicServicePath="" Enabled="True" PopupControlID="FeaturePanel"
TargetControlID="FeatureButton"></asp:ModalPopupExtender>
Protected Sub SubmitFeatures_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles SubmitFeatures.Click
FeatureModal.Hide()
For Each feature As ListItem In cbxAddFeature.Items
If feature.Selected Then
'SQL INSERT: Marketing Table
Dim strSQL As String = "INSERT INTO Marketing (ProductID,
MarketingTypeID, MarketingTitle, MarketingData)
VALUES (@ProductID, 3, 'Feature', @MarketingData);
UPDATE Product SET ModifyDate = getdate(),
ModifyUser = @ModifyUser
WHERE ProductID = @ProductID"
これは、モーダルポップアップ全体のコードであり、チェックボックスの挿入も含まれています。ユーザーに適切なチェックボックスが表示されない場合は、テキストボックスから新しい値を入力できます。
Protected Sub SubmitFeatures_Click(ByVal sender As Object, ByVal e
As System.EventArgs) Handles SubmitFeatures.Click
FeatureModal.Hide()
For Each feature As ListItem In cbxAddFeature.Items
If feature.Selected Then
Dim strSQL As String = "INSERT INTO Marketing (ProductID,
MarketingTypeID, MarketingTitle, MarketingData)
VALUES (@ProductID, 3, 'Feature', @MarketingData);
UPDATE Product SET ModifyDate = getdate(),
ModifyUser = @ModifyUser
WHERE ProductID = @ProductID"
Using cn As New SqlConnection
(System.Configuration.ConfigurationManager.ConnectionStrings
("LocalSqlServer").ConnectionString)
Using cmd As New SqlCommand(strSQL, cn)
cmd.Parameters.Add(New SqlParameter("@ProductID",
ProductID.Value))
cmd.Parameters.Add(New
SqlParameter("@MarketingData", feature.Value))
cmd.Parameters.Add(New SqlParameter("@ModifyUser",
System.Web.HttpContext.Current.User.Identity.Name))
cn.Open()
cmd.ExecuteNonQuery()
End Using
cn.Close()
End Using
Else
End If
If Not String.IsNullOrEmpty(txtFeature.Text) Then
Dim featureSql As String = "INSERT INTO Feature (FeatureTitle)
VALUES (@FeatureTitle);
INSERT INTO Marketing(ProductID,
MarketingTypeID, MarketingTitle, MarketingData)
VALUES (@ProductID, 3, 'Feature',
scope_identity());
UPDATE Product SET ModifyDate = getdate(),
ModifyUser = @ModifyUser
WHERE ProductID = @ProductID"
Using cn As New SqlConnection
(System.Configuration.ConfigurationManager.ConnectionStrings
("LocalSqlServer").ConnectionString)
Using cmd As New SqlCommand(featureSql, cn)
cmd.Parameters.Add(New SqlParameter("@FeatureTitle",
txtFeature.Text))
cmd.Parameters.Add(New SqlParameter("@ProductID",
ProductID.Value))
cmd.Parameters.Add(New SqlParameter("@ModifyUser",
System.Web.HttpContext.Current.User.Identity.Name))
cn.Open()
cmd.ExecuteNonQuery()
End Using
cn.Close()
End Using
End If
Next
'keep tab active and redirect to same page
Session("ActiveTabIdx") = TabContainer1.ActiveTabIndex
Response.Redirect(Request.RawUrl)
End Sub