Link to home
Create AccountLog in
Avatar of 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");

Gridview column
  <asp:TemplateField ItemStyle-Width="4%">
                        <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">
                                    <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"/>
                                            <asp:textbox ID="txtQtyOrdered" runat="server" Width ="100px"></asp:textbox>
Avatar of Kaushal Arora
Kaushal Arora
Flag of India image

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.

Kaushal A
Avatar of RadhaKrishnaKiJaya


Can you please show me how to do it.

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.

Kaushal Arora
I already posted the code above.


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.

Avatar of RadhaKrishnaKiJaya

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
This solution is working for me.