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

Discussion in 'ASP .Net' started by Managed Code, Jun 14, 2006.

  1. Managed Code

    Managed Code Guest

    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>
     
    Managed Code, Jun 14, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fernando Lopes
    Replies:
    0
    Views:
    3,196
    Fernando Lopes
    Apr 28, 2005
  2. phl
    Replies:
    1
    Views:
    4,354
    Martin Jay
    Jun 8, 2006
  3. sloan
    Replies:
    2
    Views:
    4,903
    aryan_subhash
    Oct 17, 2007
  4. mesut
    Replies:
    0
    Views:
    574
    mesut
    Jun 29, 2007
  5. Managed Code
    Replies:
    0
    Views:
    227
    Managed Code
    Jun 14, 2006
Loading...

Share This Page