Avatar of RadhaKrishnaKiJaya
RadhaKrishnaKiJaya
 asked on

Save a gridview data which is inside another gridview's Rowdatabound

Hi Experts,

I have a gridview. one of its column has s plus sign. When I click the plus sign it makes the other gridview visible . When I click the minus sign it is invisible. Is there anyway I can save the data of the popup gridview in a dataset or a datatable when the minus sign is clicked. I have attached the screenshots.

Thanks in advance.


Code for + and -
----------------------------

 <script  type="text/javascript" src="Jqueries/jquery_nestedGrid.min.js"></script>
     <script type="text/javascript">
         $("[src*=plus]").live("click", function () {
             $(this).closest("tr").after("<tr><td></td><td colspan = '900'>" + $(this).next().html() + "</td></tr>")
             $(this).attr("src", "images/minus.png");
             
         });
         $("[src*=minus]").live("click", function () {
             $(this).attr("src", "images/plus.png");
             $(this).closest("tr").next().remove();
         });
     </script>


Gridview column
---------------------------
  <asp:TemplateField ItemStyle-Width="4%">
                    <ItemTemplate>
                        <asp:image alt = "" style="cursor: pointer;" src="images/plus.png" id="ImgPlusMinus" runat="server" />
                        <asp:Panel ID="pnlOrders" runat="server" Style="display: none">
                            <asp:GridView ID="gvVendors" runat="server" AutoGenerateColumns="false" CssClass = "ChildGrid SetLeftMarginChildGrid">
                                <Columns>
                                    <asp:BoundField DataField="VendorID" HeaderText="ID" visible="false" />
                                    <asp:BoundField ItemStyle-Width="300px" DataField="VendorName" HeaderText="Vendor" />
                                    <asp:BoundField ItemStyle-Width="100px" DataField="PartCost" HeaderText="Part Cost" />
                                    <asp:BoundField ItemStyle-Width="200px" DataField="PreferredVendor" HeaderText="Preferred Vendor" />
                                     <asp:TemplateField HeaderText="Qty. Ordered">
                                        <HeaderStyle Width="110px" HorizontalAlign="Left"/>
                                        <ItemStyle Width="50px" HorizontalAlign="Left"/>
                                        <ItemTemplate>
                                            <asp:textbox ID="txtQtyOrdered" runat="server" Width ="100px"></asp:textbox>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </asp:Panel>
                    </ItemTemplate>
                </asp:TemplateField>
Vendor1.png
Vendor2.png
ASP.NETVisual Basic.NETC#.NET ProgrammingMicrosoft Development

Avatar of undefined
Last Comment
RadhaKrishnaKiJaya

8/22/2022 - Mon
Kaushal Arora

Hi RadhaKrishnaKiJaya,

I think one work around for you is to loop the html table in jQuery and save the data in XML format in a public variable declared in code file. You can save the data to a public variable using jQuery/JavaScript. This way you can get that XML string in code file and convert that to DataSet or DataTable. This looping will be done in this function

$("[src*=minus]").live("click", function () 

Open in new window


Hope it helps you.

Regards,
Kaushal A
RadhaKrishnaKiJaya

ASKER
Can you please show me how to do it.

Thanks.
Kaushal Arora

Yes, I can but for that I would require your code component that is the html of  the grid which is rendered in your case.

Regards,
Kaushal Arora
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
RadhaKrishnaKiJaya

ASKER
I already posted the code above.

Thanks.
Kaushal Arora

Hi,

What I meant was to provide me with the run-time Html of the Grid view so that I need not to write the full code behind logic to fill the grid and get things done for you.

Thanks.
ASKER CERTIFIED SOLUTION
RadhaKrishnaKiJaya

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
RadhaKrishnaKiJaya

ASKER
This solution is working for me.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.