By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>

Jun 14 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.