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:
<aspataList ID="dlLicenses" runat="server" Width="100%"
DataSourceID="dsLicenses">
<ItemTemplate>
<aspropDownList 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>
</aspropDownList>
</ItemTemplate>
</aspataList>
<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
I'm having an issue I can't seem to get past using databound controls.
Here is the page I'm working with:
<aspataList ID="dlLicenses" runat="server" Width="100%"
DataSourceID="dsLicenses">
<ItemTemplate>
<aspropDownList 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>
</aspropDownList>
</ItemTemplate>
</aspataList>
<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