Click here to Skip to main content
15,904,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts,

I have a gridview with two columns in it.
1st column is InventoryType and
2nd column is Inventory.

so I have 2 dropdowns in each row of the gridview.

When the grid is populated initially, InventoryType column is populated for all the data rows. After that user will select InventoryType of first row, at the movement I want to populate Inventory dropdown of the same row on the basis of InventoryType selection by the user.

I hope my question is clear to all of you.

Please help me out.

Thanks in advance,

~Amol
Posted
Comments
sahabiswarup 20-Jan-12 1:21am    
so you want a grid inside a grid?
Amol_27101982, India 23-Jan-12 7:09am    
Not exactly.

I want to have data in the same row. Wanted to populate Inventory on the basis of selection of Inventory Type as I mentioned in my question.

1 solution

Can you try the following code -

JavaScript
 <script language="javascript" type="text/javascript">
    function PopulateInventoryDropDown() {
        var InventoryDropDownID = event.srcElement.id.replace("InventoryTypeDDL", "InventoryDDL");
        // set the Inventory drop down list items here
    }
</script>

Assuming that you have declared DropDownLists inside template fields as below -
C#
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False">
    <columns>
        <asp:templatefield>
            <itemtemplate>
                <asp:dropdownlist id="InventoryTypeDDL" onchange="PopulateInventoryDropDown();" runat="server">
                </asp:dropdownlist>
            </itemtemplate>
        </asp:templatefield>
        <asp:templatefield>
            <itemtemplate>
                <asp:dropdownlist id="InventoryDDL" runat="server">
                </asp:dropdownlist>
            </itemtemplate>
        </asp:templatefield>
    </columns>
</asp:gridview>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900