dropdownlist as templatefield needs outer gridview's row value as select parameter

M

Managed Code

Hello,
I have a status and definition table. The status table's current
status field relates the ID field of the definition table. I am trying
to retrieve the definitions that are associated only with the master_id
for the status table's current status. After having some trouble
databinding I found a solution using a hidden label to save the value I
need for my select parameter. The error I am receiving is

'ddlStatus' has a SelectedValue which is invalid because it does not
exist in the list of items.
Parameter name: value

Any hints on where to go from here would be appreciated.

Thanks, MC

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="OracleDataSource1">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True"
SortExpression="ID" Visible="False" />
<asp:BoundField DataField="INSPECTION_ID" HeaderText="INSPECTION_ID"
SortExpression="INSPECTION_ID" />
<asp:TemplateField HeaderText="CURRENT_STATUS"
SortExpression="CURRENT_STATUS">
<ItemTemplate>
<%# GetStatusDisplayText( Eval("CURRENT_STATUS")) %>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlStatus" runat="server"
DataSourceID="SqlDataSource2" DataTextField="NAME" DataValueField="ID"
SelectedValue='<%# Bind("CURRENT_STATUS") %>'>
</asp:DropDownList>
<asp:Label ID="lblHidden" Visible="false" runat="server" Text =
'<%# Eval("INSPECTION_ID") %>' />
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ATLQACS %>" ProviderName="<%$
ConnectionStrings:ATLQACS.ProviderName %>" SelectCommand="select ID,
NAME from WF_DEFINITION WHERE MASTER_ID = ( select MASTER_ID from
WF_STATUS , WF_DEFINITION where WF_STATUS.CURRENT_STATUS =
WF_DEFINITION.ID and WF_STATUS.INSPECTION_ID = :INSPECTION_ID)">
<SelectParameters>
<asp:ControlParameter ControlID="lblHidden" Name="INSPECTION_ID"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="OracleDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ATLQACS %>" ProviderName="<%$
ConnectionStrings:ATLQACS.ProviderName %>" SelectCommand='SELECT "ID",
"CURRENT_STATUS", "INSPECTION_ID" FROM "WF_STATUS" ORDER BY
"INSPECTION_ID"' UpdateCommand='UPDATE "WF_STATUS" SET "CURRENT_STATUS"
= :CURRENT_STATUS, "INSPECTION_ID" = :INSPECTION_ID WHERE "ID" = :ID'>
<UpdateParameters>
<asp:parameter Name="CURRENT_STATUS" Type="Decimal" />
<asp:parameter Name="INSPECTION_ID" Type="Decimal" />
<asp:parameter Name="ID" Type="Decimal" />
</UpdateParameters>
</asp:SqlDataSource>
 

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,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top