Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
295
Requested record cannot be found by key when sqldatasource filtered
posted

Hi,

I'm using a web tree to filter my datasource by changing the selectcommand dinamically: 

 protected void WebDataTree2_OnSelectionChanged(object sender, Infragistics.Web.UI.NavigationControls.DataTreeSelectionEventArgs e)

        {

            Labelx.Text = e.NewSelectedNodes[0].Value;

 

            emp1.SelectCommand = "select sub.department_id,sub.DEPARTMENT_NAME,(select first_name from employees where employee_id = sub.manager_id) first_name,(select salary from employees where employee_id = sub.manager_id) salary,manager_id employee_id from " +

                                "( select department_name,department_id, manager_id from departments where department_id= " + Labelx.Text

                                + " )sub ";

        }

 

----------------------

then I implement update to the grid

<asp:SqlDataSource ID="emp1" runat="server"

            ConnectionString="<%$ ConnectionStrings:hr %>" 

            DeleteCommand="DELETE FROM &quot;EMPLOYEES&quot; WHERE &quot;EMPLOYEE_ID&quot; = :EMPLOYEE_ID" 

            InsertCommand="INSERT INTO &quot;EMPLOYEES&quot; (&quot;EMPLOYEE_ID&quot;, &quot;FIRST_NAME&quot;, &quot;SALARY&quot;, &quot;DEPARTMENT_ID&quot;) VALUES (:EMPLOYEE_ID, :FIRST_NAME, :SALARY, :DEPARTMENT_ID)" 

            ProviderName="<%$ ConnectionStrings:hr.ProviderName %>" 

 

 

 

            UpdateCommand="SALARY_UPDATE" UpdateCommandType="StoredProcedure" 

 

            >

           <%-- UpdateCommand="UPDATE &quot;EMPLOYEES&quot; SET &quot;FIRST_NAME&quot; = :FIRST_NAME , &quot;SALARY&quot; = :SALARY WHERE &quot;EMPLOYEE_ID&quot; = :EMPLOYEE_ID" >--%>

            <DeleteParameters>

                <asp:Parameter Name="EMPLOYEE_ID" Type="Decimal" />

            </DeleteParameters>

            <InsertParameters>

                <asp:Parameter Name="EMPLOYEE_ID" Type="Decimal" />

                <asp:Parameter Name="FIRST_NAME" Type="String" />

                <asp:Parameter Name="SALARY" Type="Decimal" />

                <asp:Parameter Name="DEPARTMENT_ID" Type="Decimal" />

            </InsertParameters>

            <UpdateParameters>

                <asp:Parameter Name="EMPLOYEE_ID" Type="Decimal" />

                <asp:Parameter Name="FIRST_NAME" Type="String" />

                <asp:Parameter Name="SALARY" Type="Decimal" />

            </UpdateParameters>

        </asp:SqlDataSource>

    </div>

     <asp:ScriptManager ID="ScriptManager2" runat="server">

    </asp:ScriptManager>

    <asp:UpdatePanel ID="pnl2" runat="server">

        <ContentTemplate>

        <asp:Button ID="btn_save" runat="server" Text="Save" />

            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

        </ContentTemplate>

    </asp:UpdatePanel>

    <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="653px" 

        AutoGenerateColumns="False" DataSourceID="emp1" 

        DataKeyFields="EMPLOYEE_ID" style="margin-right: 259px">

        <Columns>

            <ig:BoundDataField DataFieldName="DEPARTMENT_ID" Key="DEPARTMENT_ID" Width="100">

                <Header Text="DEPARTMENT_ID" />

            </ig:BoundDataField>

            <ig:BoundDataField DataFieldName="DEPARTMENT_NAME" Key="DEPARTMENT_NAME" Width="100">

                <Header Text="DEPARTMENT_NAME" />

            </ig:BoundDataField>

            <ig:BoundDataField DataFieldName="EMPLOYEE_ID" Key="EMPLOYEE_ID" Width="100" Hidden="true">

                <Header Text="EMPLOYEE_ID" />

            </ig:BoundDataField>

            <ig:BoundDataField DataFieldName="FIRST_NAME" Key="FIRST_NAME" Width="100">

                <Header Text="FIRST_NAME" />

            </ig:BoundDataField>

            <ig:BoundDataField DataFieldName="SALARY" Key="SALARY" Width="100">

                <Header Text="SALARY" />

            </ig:BoundDataField>

        </Columns>

        <Behaviors>

            <ig:EditingCore AutoCRUD="true">

                <Behaviors>

                    <ig:CellEditing>

                    </ig:CellEditing>

                    <ig:RowAdding>

                    </ig:RowAdding>

                    <ig:RowDeleting />

                </Behaviors>

            </ig:EditingCore>

            <ig:Selection CellClickAction="Row" RowSelectType="Single">

            </ig:Selection>

            <ig:RowSelectors>

            </ig:RowSelectors>

        </Behaviors>

        <Templates>

            <ig:ItemTemplate ID="WebDataGrid1Template1" runat="server" 

                TemplateID="empid_template">

                <Template><asp:Label ID="header_text" runat="server" Text="STOIIP under Reserves" ></asp:Label></Template>

            </ig:ItemTemplate>

        </Templates>

    </ig:WebDataGrid>

------------------------

it seem to work if I dont filter the records, please advise how can I make this to work.

Thanks in advance