This is a migrated thread and some comments may be shown as answers.

Selecting Griddropdown1 displaying values in Griddropdown2

1 Answer 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Syed
Top achievements
Rank 1
Syed asked on 06 May 2009, 11:10 AM
Hi,

I am displaying/inserting/deleting/updating on a RadGrid. Two of the columns are from the two different tables. I am displaying these two columns in Griddropdowncolumn when an insert/edit operations perform.

Table-1(Divisions) columns :   (PK)Division_ID, Division_Name
Table-2(Sections) Columns :   Section_ID, Section_Name, Division_ID(FK)


Table1(Divisions)              Table2(Sections)
----------------------              ----------------------
Mobile  ------------------------>Nokia
            ------------------------>Ericsson
            ------------------------>Samsug
            ------------------------>Motorola

Pens    ------------------------>rotomax
            ------------------------>calibur
            ------------------------>Halliburton

I am able to display all division in Griddropdownand all sections in another GridDropDown.  

What i need is when division mobile is selected, only  values from the mobile sections will have to display.

Please find the following code:
--------------------------------------------------------------------
<div style="text-align: center;">
        <span style="font-family: Arial; font-size: larger;">Resource Information<br />
            <br />
        </span>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
            AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowPaging="True"
            AllowSorting="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
            DataSourceID="SqlDataSource1" GridLines="None" ShowGroupPanel="True" Skin="Vista">
            <MasterTableView AutoGenerateColumns="False" CellSpacing="-1" CommandItemDisplay="TopAndBottom"
                DataKeyNames="Resource_ID" DataSourceID="SqlDataSource1" EditMode="PopUp">
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="Resource_ID" DataType="System.Int32" HeaderText="Resource_ID"
                        ReadOnly="True" SortExpression="Resource_ID" UniqueName="Resource_ID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Resource_Name" HeaderText="Resource_Name" SortExpression="Resource_Name"
                        UniqueName="Resource_Name">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Resource_Designation" HeaderText="Resource_Designation"
                        SortExpression="Resource_Designation" UniqueName="Resource_Designation">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Resource_EMail" HeaderText="Resource_EMail" SortExpression="Resource_EMail"
                        UniqueName="Resource_EMail">
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn DataField="Division_ID" DataSourceID="SqlDataSource2"
                        HeaderText="Division" ListTextField="Division_Name" ListValueField="Division_ID"
                        DataType="System.Int32" UniqueName="UniqueDivisionName">
                    </telerik:GridDropDownColumn>
                    <telerik:GridDropDownColumn DataField="Section_ID" DataSourceID="SqlDataSource3"
                        HeaderText="Section" ListTextField="Section_Name" ListValueField="Section_ID"
                        DataType="System.Int32" UniqueName="UniqueSectionName">
                    </telerik:GridDropDownColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings AllowDragToGroup="True">
            </ClientSettings>
        </telerik:RadGrid><br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ResourceUtilizationDBConnectionString %>"
            SelectCommand="SELECT * FROM [Resource_Information]" ConflictDetection="CompareAllValues"
            DeleteCommand="DELETE FROM [Resource_Information] WHERE [Resource_ID] = @original_Resource_ID AND (([Resource_Name] = @original_Resource_Name) OR ([Resource_Name] IS NULL AND @original_Resource_Name IS NULL)) AND (([Resource_Designation] = @original_Resource_Designation) OR ([Resource_Designation] IS NULL AND @original_Resource_Designation IS NULL)) AND (([Resource_EMail] = @original_Resource_EMail) OR ([Resource_EMail] IS NULL AND @original_Resource_EMail IS NULL)) AND (([Division_ID] = @original_Division_ID) OR ([Division_ID] IS NULL AND @original_Division_ID IS NULL)) AND (([Section_ID] = @original_Section_ID) OR ([Section_ID] IS NULL AND @original_Section_ID IS NULL))"
            InsertCommand="INSERT INTO [Resource_Information] ([Resource_Name], [Resource_Designation], [Resource_EMail], [Division_ID], [Section_ID]) VALUES (@Resource_Name, @Resource_Designation, @Resource_EMail, @Division_ID, @Section_ID)"
            OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Resource_Information] SET [Resource_Name] = @Resource_Name, [Resource_Designation] = @Resource_Designation, [Resource_EMail] = @Resource_EMail, [Division_ID] = @Division_ID, [Section_ID] = @Section_ID WHERE [Resource_ID] = @original_Resource_ID AND (([Resource_Name] = @original_Resource_Name) OR ([Resource_Name] IS NULL AND @original_Resource_Name IS NULL)) AND (([Resource_Designation] = @original_Resource_Designation) OR ([Resource_Designation] IS NULL AND @original_Resource_Designation IS NULL)) AND (([Resource_EMail] = @original_Resource_EMail) OR ([Resource_EMail] IS NULL AND @original_Resource_EMail IS NULL)) AND (([Division_ID] = @original_Division_ID) OR ([Division_ID] IS NULL AND @original_Division_ID IS NULL)) AND (([Section_ID] = @original_Section_ID) OR ([Section_ID] IS NULL AND @original_Section_ID IS NULL))">
            <DeleteParameters>
                <asp:Parameter Name="original_Resource_ID" Type="Int32" />
                <asp:Parameter Name="original_Resource_Name" Type="String" />
                <asp:Parameter Name="original_Resource_Designation" Type="String" />
                <asp:Parameter Name="original_Resource_EMail" Type="String" />
                <asp:Parameter Name="original_Division_ID" Type="Int32" />
                <asp:Parameter Name="original_Section_ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Resource_Name" Type="String" />
                <asp:Parameter Name="Resource_Designation" Type="String" />
                <asp:Parameter Name="Resource_EMail" Type="String" />
                <asp:Parameter Name="Division_ID" Type="Int32" />
                <asp:Parameter Name="Section_ID" Type="Int32" />
                <asp:Parameter Name="original_Resource_ID" Type="Int32" />
                <asp:Parameter Name="original_Resource_Name" Type="String" />
                <asp:Parameter Name="original_Resource_Designation" Type="String" />
                <asp:Parameter Name="original_Resource_EMail" Type="String" />
                <asp:Parameter Name="original_Division_ID" Type="Int32" />
                <asp:Parameter Name="original_Section_ID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Resource_Name" Type="String" />
                <asp:Parameter Name="Resource_Designation" Type="String" />
                <asp:Parameter Name="Resource_EMail" Type="String" />
                <asp:Parameter Name="Division_ID" Type="Int32" />
                <asp:Parameter Name="Section_ID" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ResourceUtilizationDBConnectionString %>"
            SelectCommand="SELECT [Division_ID], [Division_Name] FROM [NSS_Divisions]"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ResourceUtilizationDBConnectionString %>"
            SelectCommand="SELECT [Section_ID], [Section_Name] FROM [Division_Sections]"></asp:SqlDataSource>
    </div>
---------------------------------------------------------


Thanks.

Regards
Arshad





              

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 06 May 2009, 11:16 AM
Hi Arshad,

Check out the following online demo. It demonstrates a similar scenario when the Grid is in edit mode, In the SelectedIndexChanged event of the first DropDown access the second DropDownList and populate it accordingly
Accessing Cells and Rows

Shinu
Tags
Grid
Asked by
Syed
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or