I have a user control with a DataList object on it. Within the
<EditItemTemplate> I have a user control that is a special DropDownList
object.
<asp:DataList ID="usercontrol1" Runat="Server"
OnEditCommand="dlEdit_Command"
OnUpdateCommand="dlUpdate_Command"
OnDeleteCommand="dlDelete_Command"
OnCancelCommand="dlCancel_Command">
<ItemTemplate>
<asp:Button ID="btnEdit" Runat="server" Text="Edit" CommandName="Edit"
CommandArgument='<%# Container.DataItem("ID") %>' />
<asp:Label ID="lblItem" Runat="server" Text='<%#
Container.DataItem("Line") %>' />
</ItemTemplate>
<EditItemTemplate>
<mytag:MyDropDownList ID="ddlDropDownList" Runat="server"
SelectedValue='<%# Container.DataItem("Value") %>' />
</EditItemTemplate>
</asp:DataList>
My MyDropDownList component on page load calls a method that takes the
SelectedValue and sets the SelectedIndex of the DropDownList object in
MyDropDownList object. When I do this I receive "Object reference not set
to an instance of an object" errors. I've run tests and have found that the
SelectedValue property doesn't have a value either. It acts like the object
doesn't exist yet.
What do I have to do? What is the firing order of methods when I perform a
databind on the datalist?
Am I at least close?
Thanks, Keith Geringer