I have an application I'm working on that have multiple grid views on panels, and those panels are selected by a dropdown list. The first one I'll put here works perfectly.
I have a second grid set up exactly the same (I think) as the first. I've changed variable names a bit, and added a few extra rows for stuff, but otherwise things are identical.
On this second grid, I get an error that my first variable (LCompanyIDInt) is not declared. I have no clue why it says that.
I've pasted both the working & non-working code below. Removed a lot of columns for space reasons, but it always bombs on the LCompanyIDInt issue on the 2nd grid, for either inserting or updating. Resetting or cancelling works fine.
WORKING CODE:
<!-- Total Points Annuity -->
<asp:Panel ID="TPAnnuity_Panel" runat="server" visible="true">
<asp:GridView ID="TPAnnuity_GridView" AllowSorting="true" AllowPaging="true" Runat="server"
DataSourceID="TPAnnuity_SqlDataSource" DataKeyNames="AnnuityTotalPointsID"
AutoGenerateColumns="False" ShowFooter="true" PageSize="20">
<Columns>
<asp:TemplateField HeaderText="ID" visible="False" InsertVisible="False" SortExpression="AnnuityTotalPointsID" HeaderStyle-VerticalAlign="Bottom">
<ItemTemplate>
<asp:Label ID="Label0" runat="server" Text='<%# Bind("AnnuityTotalPointsID") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="EditAAnnuityTotalPointsID" runat="server" Text='<%# Bind("AnnuityTotalPointsID") %>'></asp:Label>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Company" SortExpression="CompanyName" HeaderStyle-VerticalAlign="Bottom">
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind("CompanyName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="EditACompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName" selectedValue='<%# Bind("CompanyID") %>'></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="NewCompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="NewCompanyID" Display="Dynamic" ForeColor="" ErrorMessage="You must enter a value. *" Enabled="false"></asp:RequiredFieldValidator>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
<etc I ran out of room>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CausesValidation="False" CommandName="Update" Text="Update" ></asp:LinkButton>
<asp:LinkButton ID="lbCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lbInsert" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" ></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Reset"></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="TPAnnuity_SqlDataSource" Runat="server"
SelectCommand="SELECT * FROM tblTotalPointsAnnuity a left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
InsertCommand="INSERT INTO [tblTotalPointsAnnuity](CompanyID, ProductName, IssueAges, PlanTypeName, AgentFYC, AgentRenewal, ContractPoints, BonusPoints, IncludeInSummary, IncludeInTopPicks, ActiveProduct) VALUES(@CompanyIDInt, @ProductNameText, @IssueAgesText, @PlanTypeNameText, @AgentFYCInt, @AgentRenewalInt, @ContractPointsDec, @BonusPointsInt, @IncludeInSummaryInt, @IncludeInTopPicksInt, @ActiveProductInt) "
UpdateCommand="UPDATE [tblTotalPointsAnnuity] Set CompanyID = @CompanyIDInt, ProductName = @ProductNameText, IssueAges = @IssueAgesText, PlanTypeName = @PlanTypeNameText, AgentFYC = @AgentFYCInt, AgentRenewal = @AgentRenewalInt, ContractPoints = @ContractPointsDec, BonusPoints = @BonusPointsInt, IncludeInSummary = @IncludeInSummaryInt, IncludeInTopPicks = @IncludeInTopPicksInt, ActiveProduct = @ActiveProductInt WHERE [AnnuityTotalPointsID] = @AnnuityTotalPointsIDInt">
<InsertParameters>
<asp:Parameter Name="CompanyIDInt" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="CompanyIDInt" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</asp:Panel>
<!-- END Total Points Annuity -->
WORKING CODE BEHIND
Sub TPAnnuity_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles TPAnnuity_GridView.RowCommand
Dim TPAnnuity_searchStr As String = TPAnnuity_search_Text.Text
If TPAnnuity_searchStr = "" Then
TPAnnuity_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsAnnuity a " & _
" left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
" ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
Else
TPAnnuity_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsAnnuity a " & _
" left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
"WHERE 1=1 "
If TPAnnuity_search_dropdown.SelectedValue = "Company" Then
TPAnnuity_SqlDataSource.SelectCommand &= " AND ci.CompanyName like '%" & TPAnnuity_search_Text.Text & "%' OR ci.CompanyCode like '%" & TPAnnuity_search_Text.Text & "%'"
Else If TPAnnuity_search_dropdown.SelectedValue = "CompanyID" Then
TPAnnuity_SqlDataSource.SelectCommand &= " AND ci.CompanyID = " & TPAnnuity_search_Text.Text
Else
TPAnnuity_SqlDataSource.SelectCommand &= " AND " & TPAnnuity_search_dropdown.SelectedValue & " like '%" & TPAnnuity_search_Text.Text & "%' "
End If
TPAnnuity_SqlDataSource.SelectCommand &= " ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
End If
If e.CommandName = "Cancel" Then
CType(TPAnnuity_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedIndex = 0
CType(TPAnnuity_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text = ""
CType(TPAnnuity_GridView.FooterRow.FindControl("NewIssueAges"), TextBox).Text = ""
CType(TPAnnuity_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text = ""
CType(TPAnnuity_GridView.FooterRow.FindControl("NewAgentFYC"), TextBox).Text = ""
CType(TPAnnuity_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text = ""
CType(TPAnnuity_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text = ""
CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex = 0
CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex = 0
CType(TPAnnuity_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex = 0
ElseIf e.CommandName = "Insert" Then
TPAnnuity_SqlDataSource.InsertParameters.Clear()
Dim test1 As New Parameter("CompanyIDInt", TypeCode.Int32)
Dim test2 As New Parameter("ProductNameText", TypeCode.String)
Dim test3 As New Parameter("IssueAgesText", TypeCode.String)
Dim test4 As New Parameter("PlanTypeNameText", TypeCode.String)
Dim test5 As New Parameter("AgentFYCInt", TypeCode.Int32)
Dim test6 As New Parameter("AgentRenewalInt", TypeCode.String)
Dim test7 As New Parameter("ContractPointsDec", TypeCode.Decimal)
Dim test8 As New Parameter("BonusPointsInt", TypeCode.Decimal)
Dim test9 As New Parameter("IncludeInSummaryInt", TypeCode.Byte)
Dim test10 As New Parameter("IncludeInTopPicksInt", TypeCode.Byte)
Dim test11 As New Parameter("ActiveProductInt", TypeCode.Byte)
test1.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedValue
test2.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text
test3.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewIssueAges"), TextBox).Text
test4.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text
test5.DefaultValue = Utils.NumOrNull(CType(TPAnnuity_GridView.FooterRow.FindControl("NewAgentFYC"), TextBox).Text)
test6.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewAgentRenewal"), TextBox).Text
test7.DefaultValue = Utils.NumOrNull(CType(TPAnnuity_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text)
test8.DefaultValue = Utils.NumOrNull(CType(TPAnnuity_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text)
test9.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex
test10.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex
test11.DefaultValue = CType(TPAnnuity_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex
TPAnnuity_SqlDataSource.InsertParameters.Add(test1)
TPAnnuity_SqlDataSource.InsertParameters.Add(test2)
TPAnnuity_SqlDataSource.InsertParameters.Add(test3)
TPAnnuity_SqlDataSource.InsertParameters.Add(test4)
TPAnnuity_SqlDataSource.InsertParameters.Add(test5)
TPAnnuity_SqlDataSource.InsertParameters.Add(test6)
TPAnnuity_SqlDataSource.InsertParameters.Add(test7)
TPAnnuity_SqlDataSource.InsertParameters.Add(test8)
TPAnnuity_SqlDataSource.InsertParameters.Add(test9)
TPAnnuity_SqlDataSource.InsertParameters.Add(test10)
TPAnnuity_SqlDataSource.InsertParameters.Add(test11)
TPAnnuity_SqlDataSource.Insert()
ElseIf e.CommandName = "Update" Then
TPAnnuity_SqlDataSource.UpdateParameters.Clear()
Dim param1 As New Parameter("CompanyIDInt", TypeCode.Int32)
Dim param2 As New Parameter("ProductNameText", TypeCode.String)
Dim param3 As New Parameter("IssueAgesText", TypeCode.String)
Dim param4 As New Parameter("PlanTypeNameText", TypeCode.String)
Dim param5 As New Parameter("AgentFYCInt", TypeCode.Int32)
Dim param6 As New Parameter("AgentRenewalInt", TypeCode.String)
Dim param7 As New Parameter("ContractPointsDec", TypeCode.Decimal)
Dim param8 As New Parameter("BonusPointsInt", TypeCode.Decimal)
Dim param9 As New Parameter("IncludeInSummaryInt", TypeCode.Int32)
Dim param10 As New Parameter("IncludeInTopPicksInt", TypeCode.Int32)
Dim param11 As New Parameter("ActiveProductInt", TypeCode.Int32)
Dim param12 As New Parameter("AnnuityTotalPointsIDInt", TypeCode.Int32)
param1.DefaultValue = CType(e.CommandSource.FindControl("EditACompanyID"), DropDownList).SelectedValue
param2.DefaultValue = CType(e.CommandSource.FindControl("EditAProductName"), TextBox).Text
param3.DefaultValue = CType(e.CommandSource.FindControl("EditAIssueAges"), TextBox).Text
param4.DefaultValue = CType(e.CommandSource.FindControl("EditAPlanTypeName"), TextBox).Text
param5.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditAAgentFYC"), TextBox).Text)
param6.DefaultValue = CType(e.CommandSource.FindControl("EditAAgentRenewal"), TextBox).Text
param7.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditAContractPoints"), TextBox).Text)
param8.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditABonusPoints"), TextBox).Text)
param9.DefaultValue = CType(e.CommandSource.FindControl("EditAIncludeInSummary"), DropDownList).SelectedIndex
param10.DefaultValue = CType(e.CommandSource.FindControl("EditAIncludeInTopPicks"), DropDownList).SelectedIndex
param11.DefaultValue = CType(e.CommandSource.FindControl("EditAActiveProduct"), DropDownList).SelectedIndex
param12.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditAAnnuityTotalPointsID"), Label).Text)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param1)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param2)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param3)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param4)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param5)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param6)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param7)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param8)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param9)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param10)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param11)
TPAnnuity_SqlDataSource.UpdateParameters.Add(param12)
TPAnnuity_SqlDataSource.Update()
End If
End Sub
NOT WORKING CODE
<!-- Total Points Life -->
<asp:Panel ID="TPLife_Panel" runat="server" visible="false">
<hr />
<table>
<tr>
<td>Search on </td>
<td>
<asp:DropDownList ID="TPLife_search_dropdown" runat="server">
<asp:ListItem Text="Company" Value="Company"></asp:ListItem>
<asp:ListItem Text="Company ID" Value="CompanyID"></asp:ListItem>
<asp:ListItem Text="Product Name" Value="ProductName"></asp:ListItem>
</asp:DropDownList>
</td>
<td> for </td>
<td>
<asp:TextBox ID="TPLife_search_Text" runat="server"></asp:TextBox>
</td>
<td>
<asp:Button ID="TPLife_search_Button" runat="server" Text="Search" OnClick="TPLife_search_Click" CssClass="buttonstyle" onmouseover="shade(this);" onmouseout="unshade(this);" />
</td>
</tr>
</table>
<asp:GridView ID="TPLife_GridView" AllowSorting="true" AllowPaging="true" Runat="server"
DataSourceID="TPLife_SqlDataSource" DataKeyNames="LifeTotalPointsID"
AutoGenerateColumns="False" ShowFooter="true" PageSize="20">
<Columns>
<asp:TemplateField HeaderText="ID" visible="False" InsertVisible="False" SortExpression="LifeTotalPointsID" HeaderStyle-VerticalAlign="Bottom">
<ItemTemplate>
<asp:Label ID="Label0" runat="server" Text='<%# Bind("LifeTotalPointsID") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="EditLLifeTotalPointsID" runat="server" Text='<%# Bind("LifeTotalPointsID") %>'></asp:Label>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Company" SortExpression="CompanyName" HeaderStyle-VerticalAlign="Bottom">
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind("CompanyName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="EditLCompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName" selectedValue='<%# Bind("CompanyID") %>'></asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="NewCompanyID" runat="server" DataSource="<%# ddlCompanyDS %>" DataValueField="CompanyID" DataTextField="CompanyName"></asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="NewCompanyID" Display="Dynamic" ForeColor="" ErrorMessage="You must enter a value. *" Enabled="false"></asp:RequiredFieldValidator>
</FooterTemplate>
<FooterStyle Wrap="False" />
</asp:TemplateField>
<etc I ran out of room>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" ></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="lbUpdate" runat="server" CausesValidation="False" CommandName="Update" Text="Update" ></asp:LinkButton>
<asp:LinkButton ID="lbCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lbInsert" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" ></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Reset"></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="TPLife_SqlDataSource" Runat="server"
SelectCommand="SELECT * FROM tblTotalPointsLife a left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
InsertCommand="INSERT INTO [tblTotalPointsAnnuity](CompanyID, ProductName, PlanTypeName, StandardAgtFYC, StandardFYCExcess, StandardRenewal, PreferredAgtFYC, PreferredFYCExcess, PreferredRenewal, ContractPoints, BonusPoints, IncludeInSummary, IncludeInTopPicks, ActiveProduct) VALUES(@LCompanyIDInt, @LProductNameText, @LPlanTypeNameText, @LStandardAgtFYCInt, @LStandardFYCExcessInt, @LStandardRenewalInt, @LPreferredAgtFYCInt, @LPreferredFYCExcessInt, @LPreferredRenewalInt, @LContractPointsDec, @LBonusPointsInt, @LIncludeInSummaryInt, @LIncludeInTopPicksInt, @LActiveProductInt) "
UpdateCommand="UPDATE [tblTotalPointsAnnuity] Set CompanyID = @LCompanyIDInt, ProductName = @LProductNameTest = @LProductNameText, IssueAges = @LIssueAgesText, PlanTypeName = @LPlanTypeNameText, StandardAgtFYC = @LStandardAgtFYCInt, StandardFYCExcess = @LStandardFYCExcessInt, StandardRenewal = @LStandardRenewalInt, PreferredAgtFYC = @LPreferredAgtFYCInt, PreferredFYCExcess = @LPreferredFYCExcessInt, PreferredRenewal = @LPreferredRenewalInt, ContractPoints = @LContractPointsDec, BonusPoints = @LBonusPointsInt, IncludeInSummary = @LIncludeInSummaryInt, IncludeInTopPicks = @LIncludeInTopPicksInt, ActiveProduct = @LActiveProductInt WHERE [LifeTotalPointsID] = @LLifeTotalPointsIDInt">
<InsertParameters>
<asp:Parameter Name="LCompanyIDInt" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="LCompanyIDInt" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</asp:Panel>
<!-- END Total Points Life -->
NOT WORKING CODE BEHIND
Sub TPLife_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles TPLife_GridView.RowCommand
Dim TPLife_searchStr As String = TPLife_search_Text.Text
If TPLife_searchStr = "" Then
TPLife_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsLife a " & _
" left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
" ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
Else
TPLife_SqlDataSource.SelectCommand = "SELECT * FROM tblTotalPointsLife a " & _
" left outer join tblcompanyinfo ci on a.CompanyID = ci.CompanyID " & _
"WHERE 1=1 "
If TPLife_search_dropdown.SelectedValue = "Company" Then
TPLife_SqlDataSource.SelectCommand &= " AND ci.CompanyName like '%" & TPLife_search_Text.Text & "%' OR ci.CompanyCode like '%" & TPLife_search_Text.Text & "%'"
Else If TPLife_search_dropdown.SelectedValue = "CompanyID" Then
TPLife_SqlDataSource.SelectCommand &= " AND ci.CompanyID = " & TPLife_search_Text.Text
Else
TPLife_SqlDataSource.SelectCommand &= " AND " & TPLife_search_dropdown.SelectedValue & " like '%" & TPLife_search_Text.Text & "%' "
End If
TPLife_SqlDataSource.SelectCommand &= " ORDER BY (CASE WHEN CompanyName Is Null then 1 ELSE 0 END), CompanyName, ProductName "
End If
If e.CommandName = "Cancel" Then
CType(TPLife_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedIndex = 0
CType(TPLife_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewStandardAgtFYC"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewStandardFYCExcess"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewStandardRenewal"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewPreferredAgtFYC"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewPreferredFYCExcess"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewPreferredRenewal"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text = ""
CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex = 0
CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex = 0
CType(TPLife_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex = 0
ElseIf e.CommandName = "Insert" Then
TPLife_SqlDataSource.InsertParameters.Clear()
Dim test1 As New Parameter("LCompanyIDInt", TypeCode.Int32)
Dim test2 As New Parameter("LProductNameText", TypeCode.String)
Dim test3 As New Parameter("LPlanTypeNameText", TypeCode.String)
Dim test4 As New Parameter("LStandardAgtFYCInt", TypeCode.Int32)
Dim test5 As New Parameter("LStandardFYCExcessInt", TypeCode.Int32)
Dim test6 As New Parameter("LStandardRenewalInt", TypeCode.Int32)
Dim test7 As New Parameter("LPreferredAgtFYCInt", TypeCode.Int32)
Dim test8 As New Parameter("LPreferredFYCExcessInt", TypeCode.Int32)
Dim test9 As New Parameter("LPreferredRenewalInt", TypeCode.Int32)
Dim test10 As New Parameter("LContractPointsDec", TypeCode.Decimal)
Dim test11 As New Parameter("LBonusPointsInt", TypeCode.Decimal)
Dim test12 As New Parameter("LIncludeInSummaryInt", TypeCode.Byte)
Dim test13 As New Parameter("LIncludeInTopPicksInt", TypeCode.Byte)
Dim test14 As New Parameter("LActiveProductInt", TypeCode.Byte)
test1.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewCompanyID"), DropDownList).SelectedValue
test2.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewProductName"), TextBox).Text
test3.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewPlanTypeName"), TextBox).Text
test4.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewStandardAgtFYC"), TextBox).Text)
test5.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewStandardFYCExcess"), TextBox).Text)
test6.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewStandardRenewal"), TextBox).Text)
test7.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewPreferredAgtFYC"), TextBox).Text)
test8.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewPreferredFYCExcess"), TextBox).Text)
test9.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewPreferredRenewal"), TextBox).Text)
test10.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewContractPoints"), TextBox).Text)
test11.DefaultValue = Utils.NumOrNull(CType(TPLife_GridView.FooterRow.FindControl("NewBonusPoints"), TextBox).Text)
test12.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInSummary"), DropDownList).SelectedIndex
test13.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewIncludeInTopPicks"), DropDownList).SelectedIndex
test14.DefaultValue = CType(TPLife_GridView.FooterRow.FindControl("NewActiveProduct"), DropDownList).SelectedIndex
TPAnnuity_SqlDataSource.InsertParameters.Add(test1)
TPAnnuity_SqlDataSource.InsertParameters.Add(test2)
TPAnnuity_SqlDataSource.InsertParameters.Add(test3)
TPAnnuity_SqlDataSource.InsertParameters.Add(test4)
TPAnnuity_SqlDataSource.InsertParameters.Add(test5)
TPAnnuity_SqlDataSource.InsertParameters.Add(test6)
TPAnnuity_SqlDataSource.InsertParameters.Add(test7)
TPAnnuity_SqlDataSource.InsertParameters.Add(test8)
TPAnnuity_SqlDataSource.InsertParameters.Add(test9)
TPAnnuity_SqlDataSource.InsertParameters.Add(test10)
TPAnnuity_SqlDataSource.InsertParameters.Add(test11)
TPAnnuity_SqlDataSource.InsertParameters.Add(test12)
TPAnnuity_SqlDataSource.InsertParameters.Add(test13)
TPAnnuity_SqlDataSource.InsertParameters.Add(test14)
TPLife_SqlDataSource.Insert() ***FAILS ON THIS LINE***
ElseIf e.CommandName = "Update" Then
TPLife_SqlDataSource.UpdateParameters.Clear()
Dim param1 As New Parameter("LCompanyIDInt", TypeCode.Int32)
Dim param2 As New Parameter("LProductNameText", TypeCode.String)
Dim param3 As New Parameter("LPlanTypeNameText", TypeCode.String)
Dim param4 As New Parameter("LStandardAgtFYCInt", TypeCode.Int32)
Dim param5 As New Parameter("LStandardFYCExcessInt", TypeCode.Int32)
Dim param6 As New Parameter("LStandardRenewalInt", TypeCode.Int32)
Dim param7 As New Parameter("LPreferredAgtFYCInt", TypeCode.Int32)
Dim param8 As New Parameter("LPreferredFYCExcessInt", TypeCode.Int32)
Dim param9 As New Parameter("LPreferredRenewalInt", TypeCode.Int32)
Dim param10 As New Parameter("LContractPointsDec", TypeCode.Decimal)
Dim param11 As New Parameter("LBonusPointsInt", TypeCode.Decimal)
Dim param12 As New Parameter("LIncludeInSummaryInt", TypeCode.Byte)
Dim param13 As New Parameter("LIncludeInTopPicksInt", TypeCode.Byte)
Dim param14 As New Parameter("LActiveProductInt", TypeCode.Byte)
Dim param15 As New Parameter("LLifeTotalPointsIDInt", TypeCode.Int32)
param1.DefaultValue = CType(e.CommandSource.FindControl("EditLCompanyID"), DropDownList).SelectedValue
param2.DefaultValue = CType(e.CommandSource.FindControl("EditLProductName"), TextBox).Text
param3.DefaultValue = CType(e.CommandSource.FindControl("EditLPlanTypeName"), TextBox).Text
param4.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLStandardAgtFYC"), TextBox).Text)
param5.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLStandardFYCExcess"), TextBox).Text)
param6.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLStandardRenewal"), TextBox).Text)
param7.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLPreferredAgtFYC"), TextBox).Text)
param8.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLPreferredFYCExcess"), TextBox).Text)
param9.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLPreferredRenewal"), TextBox).Text)
param10.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLContractPoints"), TextBox).Text)
param11.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLBonusPoints"), TextBox).Text)
param12.DefaultValue = CType(e.CommandSource.FindControl("EditLIncludeInSummary"), DropDownList).SelectedIndex
param13.DefaultValue = CType(e.CommandSource.FindControl("EditLIncludeInTopPicks"), DropDownList).SelectedIndex
param14.DefaultValue = CType(e.CommandSource.FindControl("EditLActiveProduct"), DropDownList).SelectedIndex
param15.DefaultValue = Utils.NumOrNull(CType(e.CommandSource.FindControl("EditLLifeTotalPointsID"), Label).Text)
TPAnnuity_SqlDataSource.InsertParameters.Add(param1)
TPAnnuity_SqlDataSource.InsertParameters.Add(param2)
TPAnnuity_SqlDataSource.InsertParameters.Add(param3)
TPAnnuity_SqlDataSource.InsertParameters.Add(param4)
TPAnnuity_SqlDataSource.InsertParameters.Add(param5)
TPAnnuity_SqlDataSource.InsertParameters.Add(param6)
TPAnnuity_SqlDataSource.InsertParameters.Add(param7)
TPAnnuity_SqlDataSource.InsertParameters.Add(param8)
TPAnnuity_SqlDataSource.InsertParameters.Add(param9)
TPAnnuity_SqlDataSource.InsertParameters.Add(param10)
TPAnnuity_SqlDataSource.InsertParameters.Add(param11)
TPAnnuity_SqlDataSource.InsertParameters.Add(param12)
TPAnnuity_SqlDataSource.InsertParameters.Add(param13)
TPAnnuity_SqlDataSource.InsertParameters.Add(param14)
TPAnnuity_SqlDataSource.InsertParameters.Add(param15)
TPLife_SqlDataSource.Update() ***FAILS ON THIS LINE***
End If
End Sub
I've tried comparing both front & back codes, and can't see the issue. I've tried making the 2nd panel visible by default, and it doesn't change anything. The reset function works fine on the 2nd grid, but the insert and update commands don't.
Aucun commentaire:
Enregistrer un commentaire