Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have griview which i have child gridview which open on linkbutton click. and in child gridview i hav dispatch button.onclick of that the data is being saved in databse. after the data is being saved i want to close the nested gridview by making tr.visible=false but not able to do...
and also whenever i click on linkbutton of parent gridview it should check whether child gridview is open in any of the row..if its open then it should be closed and after that on which row it was clicked it should open the child gridview for that particular row.

ASP.NET
<asp:GridView ID="grdOrderDetails" runat="server" OnRowCommand="grdOrderDetails_RowCommand" OnRowDataBound="grdOrderDetails_RowDataBound"
             OnPageIndexChanging="grdOrderDetails_PageIndexChanging" AllowPaging="true" AutoGenerateColumns="false" DataKeyNames="OrderId">
                <columns>
                    <asp:TemplateField HeaderText="OrderID"  Visible="false">
                        <itemtemplate>
                            <asp:Label ID="lblOrderId" runat="server" Text='<%# Eval("OrderId") %>'>
                        </itemtemplate>
                    
                    <asp:TemplateField HeaderText="Sr No.">
                        <itemtemplate>
                            <asp:Label ID="lblSrNo" runat="server"><%# Container.DataItemIndex + 1 %>
                        </itemtemplate>
                    
                    <asp:BoundField DataField="ClientName" HeaderText="Client Name" />
                    <asp:BoundField DataField="LocName" HeaderText="Location Name" />
                    <asp:BoundField DataField="AddressName" HeaderText="Address Name" />
                    <asp:TemplateField HeaderText="Dispatch Order">
                        <itemtemplate>
                            <asp:LinkButton ID="lnkDispatch" runat="server" Text="Dispatch" CommandName="Dispatch" CommandArgument='<%#Eval("OrderId") %>' OnClick="lnkDispatch_Click" >
                        </itemtemplate>
                    
                    <asp:TemplateField HeaderText="Cancel Order">
                        <itemtemplate>
                            <asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" OnClientClick="return confirm('Are you sure you want to cancel this order?')" CommandName="cDelete" CommandArgument='<%#Eval("OrderId") %>'>
                            
                        </itemtemplate>
                    
                    <asp:TemplateField>
                     <itemtemplate>
                        <tr id="tr"  runat="server" visible="false">
                         
                         <td id="td1"  runat="server" >
                         <td id="td2" colspan="999"  runat="server">
                                <asp:GridView ID="grdDispatch" runat="server" AutoGenerateColumns="false" 
                                    AllowPaging="true" Width="100%" OnRowDataBound="grdDispatch_RowDataBound" OnRowCommand="grdDispatch_RowCommand">
                                    <columns>
                                    <asp:TemplateField HeaderText="Order Id" Visible="false">
                                        <itemtemplate>
                                            <asp:Label ID="OrderId" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "OrderId") %>'>
                                        </itemtemplate>
                                    
                                    <asp:TemplateField HeaderText="Delivery Type">
                                            <itemtemplate>
                                                <asp:DropDownList ID="ddlDeliveryType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlDeliveryType_SelectedIndexChanged">
                                                    <asp:ListItem Text="--Select--" Value="0">
                                                    <asp:ListItem Text="Hand Delivery" Value="1">
                                                    <asp:ListItem Text="Courier" Value="2">
                                                
                                            </itemtemplate>
                                        
                                        <asp:TemplateField HeaderText="Courier Name" Visible="true">
                                            <itemtemplate>
                                                <asp:DropDownList ID="ddlCourier" runat="server">
                                            </itemtemplate>
                                        
                                        <asp:TemplateField HeaderText="Courier Receipt No." Visible="true">
                                            <itemtemplate>
                                                <asp:TextBox ID="txtCourierNo" runat="server">
                                            </itemtemplate>
                                        
                                        <asp:TemplateField HeaderText="Dipatch">
                                            <itemtemplate>
                                                <asp:Button ID="btnUpdate" runat="server" Text="Dispatch" CommandName="cUpdate" CommandArgument='<%#((GridViewRow)Container).RowIndex%>' />
                                            </itemtemplate>
                                        
                                        <asp:TemplateField HeaderText="Cancel">
                                            <itemtemplate>
                                                <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancelUpt_Click" />
                                            </itemtemplate>
                                        
                                    </columns>
                                
                                 
                        
                     </itemtemplate>
                    
                </columns>
Posted
Updated 25-Aug-15 1:33am
v3

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