Nested Databound Controls

M

Matt MacDonald

Hi all,
I'm having an issue I can't seem to get past using databound controls.
Here is the page I'm working with:


<asp:DataList ID="dlLicenses" runat="server" Width="100%"
DataSourceID="dsLicenses">

<ItemTemplate>

<asp:DropDownList ID="cboState" runat="server" AppendDataBoundItems="True"
AutoPostBack="True"

DataSourceID="dsStates" DataTextField="StateName" DataValueField="StateID"
OnSelectedIndexChanged="cboState_SelectedIndexChanged"

SelectedValue='<%# Eval("StateID") %>'>

<asp:ListItem Value="0">Select a State...</asp:ListItem>

</asp:DropDownList>

</ItemTemplate>

</asp:DataList>

<asp:ObjectDataSource ID="dsLicenses" runat="server"
OldValuesParameterFormatString="original_{0}"

SelectMethod="GetLicensesForStudent" TypeName="LicensesBLL">

<SelectParameters>

<asp:ControlParameter ControlID="lblStudentID" Name="StudentID"
PropertyName="Text"

Type="Int32" />

</SelectParameters>

</asp:ObjectDataSource>



<asp:ObjectDataSource ID="dsStates" runat="server"
OldValuesParameterFormatString="original_{0}"

SelectMethod="GetStates" TypeName="StatesBLL"></asp:ObjectDataSource>


So the idea is that I have a datalist that binds to one datasource, and a
dropdown list inside the item template that binds to another. The problem
I'm having is that when the datalist binds to its datasource, the dropdown
list hasn't been bound yet. Therefore, if the value for StateID is anything
other than 0, an exception is thrown. As has been said in previous posts,
the itemdatabound event won't help me because that doesn't fire until after
it tries to bind.

Anyone have any suggestion? I've been trying everything I can think of and
nothing is working.

Thanks in advance,
Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top