JessyRobinson1234
asked on
Object reference not set to an instance of an object.
I have the following scenario. Users can select values from a drop down list and when the selected value changes it triggers the ddlMovement_SelectedIndexC hanged. However I am getting the "Object reference not set to an instance of an object." error on line rEShipper.Visible = False. Can someone assist please?
Which gets triggered by the aspx page:
Protected Sub ddlMovement_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ddlMovement As DropDownList = fvShip.FindControl("ddlMovement")
Dim rEShipper As TableRow = fvShip.FindControl("rEShipper")
If ddlMovement.SelectedValue = "ADDITIONAL RECOVERY" Then
rEShipper.Visible = False
Else
rEShipper.Visible = True
End If
End Sub
Which gets triggered by the aspx page:
<asp:FormView ID="fvShip" runat="server" DataSourceID="sdsShipDetail" CellPadding="0">
<EditItemTemplate>
<table border="0" id="EditTable">
<tr>
<td align="left">Type of Movement:</td>
<td align="left" colspan="4"><asp:DropDownList ID="ddlMovement" SelectedValue='<%# Bind("Movement_Name")%>' runat="server" DataSourceID="sdsMovement" DataTextField="Movement_Name"
DataValueField="Movement_Name" CssClass="form" AutoPostBack="True" OnSelectedIndexChanged="ddlMovement_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="sdsMovement" runat="server" ConnectionString="<%$ ConnectionStrings:BusDevConnectionString %>"
SelectCommand="View_Movement_DD_Dell" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" ValidationGroup="PIRUpdate"
CommandName="Update" Text="Update" ></asp:LinkButton>
</td>
<td colspan="4">
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</td>
</tr>
</table>
<div>
</div>
</EditItemTemplate>
ASKER
Sorry I should have put that in there as well. Here's the aspx code reposted
<asp:FormView ID="fvShip" runat="server" DataSourceID="sdsShipDetail" CellPadding="0">
<EditItemTemplate>
<table border="0" id="EditTable">
<tr>
<td align="left">Type of Movement:</td>
<td align="left" colspan="4"><asp:DropDownList ID="ddlMovement" SelectedValue='<%# Bind("Movement_Name")%>' runat="server" DataSourceID="sdsMovement" DataTextField="Movement_Name"
DataValueField="Movement_Name" CssClass="form" AutoPostBack="True" OnSelectedIndexChanged="ddlMovement_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="sdsMovement" runat="server" ConnectionString="<%$ ConnectionStrings:BusDevConnectionString %>"
SelectCommand="View_Movement_DD_Dell" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
</td>
</tr>
<tr id="reShipper">
<td align="left">Shipper Nbr / Return to Plant / Sort / IP:</td>
<td align="left" colspan="4"><asp:TextBox ID="txtShipper" runat="server" CssClass="form" Width="200px" Text='<%# Bind("Ship_Nbr") %>'></asp:textbox>
</td>
</tr>
<tr>
<td>
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" ValidationGroup="PIRUpdate"
CommandName="Update" Text="Update" ></asp:LinkButton>
</td>
<td colspan="4">
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</td>
</tr>
</table>
<div>
</div>
</EditItemTemplate>
I would assume it has to do with the fact that in the aspx code it is called reShipper as ID, but in your code you are looking for rEShipper.
ASKER
I changed it to be rEShipper but same error...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim rEShipper As TableRow = fvShip.FindControl("rEShip
is not returning anything. (null)
I can't see a control called rEShipper in the mark up posted