Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Developers
I'm stuck on one problem in that I've a Parent GridView and Child Grid View And Child GridView has multiple rows and single column in the row I'm storing the Dropdown and next to dropdown I've a LinkButton for Download the file which is shown in dropdownlist.
What I've to do is When user Click on Down button I've to download the file whatever user selected from DropDownList So When I try to click on Download I don't know how to find the dropdownlist of child GridView

What I have tried:

<asp:gridview id="ParentGV" runat="server">
<asp:gridview id="ChildGV" runat="server">
<asp:dropdownlist id="FileList" runat="server">
<asp:listitem value="a.jpg" text="a.jpg">
<asp:listitem value="b.jpg" text="b.jpg">
<asp:listitem value="c.jpg" text="c.jpg">

<asp:linkbutton id="lnkDownloadFile" text="Download" onclick="DownLoad_click" runat="server">
Posted
Updated 9-Sep-20 1:32am

1 solution

Assuming the link button and list are in the same grid row, try:
C#
protected void Download_click(object sender, EventArgs e)
{
    var button = (Control)sender;
    var list = (DropDownList)button.NamingContainer.FindControl("FileList");
    string file = list.SelectedValue;
    ...
}
 
Share this answer
 
Comments
Member 14886708 9-Sep-20 8:15am    
Wow, Thanks, I wasn't aware about naming container Thanks for your support and your time @Richard Deeming

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