EDN Admin
Well-known member
<pre class="prettyprint" style=" [/code]
<pre class="prettyprint" style=" Hi , When the Parent GridView dgParent first column image is clicked, the child gridview dgChild is expanding but when the childgridview dgChild first column image is clicked without expanding the next child gridview dgChildChild, it is collapsing back to the parent dgParent. Here Input is InwardNo. <script type="text/javascript
function switchViews(obj, row)
{
var div = document.getElementById(obj);
var img = document.getElementById(img + obj);
if (div.style.display == "none")
{
div.style.display = "inline";
img.src = "../minus.png";
}
else {
div.style.display = "none";
img.src = "../plus.png";
}
}
function switchViews1(obj, row) {
var div = document.getElementById(obj);
var img = document.getElementById(img + obj); if (div.style.display == "none") { div.style.display = "inline";
img.src = "../plus.png";
}
else {
div.style.display = "none";
img.src = "../plus.png";
}
}
</script> [/code]
<pre class="prettyprint" style=" <asp:GridView ID="dgParent" BorderStyle="Solid" GridLines="none" runat="server" DataKeyField="InwardNo" OnRowDataBound="dgParent_RowDataBound" AutoGenerateColumns="False" Width="95%
<Columns>
<asp:TemplateField>
<ItemTemplate>
JavaScript:switchViews(div<%# Eval("InwardNo") %>,one);
<img id="imgdiv<%# Eval("InwardNo") %>" alt="Click to show/hide orders" width="9px" border="0" src="../plus.gif" />
</ItemTemplate>
<AlternatingItemTemplate>
javascript:switchViews(div<%# Eval("InwardNo") %>, alt);
<img id="imgdiv<%# Eval("InwardNo") %>" alt="Click to show/hide orders" border="0" src="../minus.gif" />
</AlternatingItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="InwardNo" HeaderText="InwardNo" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="ReceivedDate" HeaderText="ReceivedDate" DataFormatString="{0:d}" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="LetterNo" HeaderText="LetterNo" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="ConsignmentNo" HeaderText="ConsignmentNo" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Status" HeaderText="Status" HeaderStyle-CssClass="tableHeadTxt" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%
<div id="div<%# Eval("InwardNo") %>" style="display: none; ; >
<asp:GridView ID="dgChild" DataKeyField="InwardNo" GridLines="none" EmptyDataText="Data is not found." OnRowDataBound="dgChild_RowDataBound" runat="server" AutoGenerateColumns="false" Width="95%
<Columns>
<asp:TemplateField ItemStyle-Width="20px
<ItemTemplate>
JavaScript:switchViews1(div<%# Eval("Itemno") %>,one);
<img id="imgdiv<%# Eval("Itemno") %>" alt="Click to show/hide orders" width="9px" border="0" src="../plus.gif" />
</ItemTemplate>
<AlternatingItemTemplate>
javascript:switchViews1(div<%# Eval("Itemno") %>, alt);
<img id="imgdiv<%# Eval("Itemno") %>" alt="Click to show/hide orders" border="0" src="../Plus.gif" />
</AlternatingItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ItemCode" HeaderText= "ItemCode" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="ItemName" HeaderText= "ItemName" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Lab" HeaderText= "Lab" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Itemno" HeaderText="Itemno" Visible="false" HeaderStyle-CssClass="tableHeadTxt" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%
<div id="div<%# Eval("Itemno") %>" style="display: none; ; >
<asp:GridView ID="dgChildChild" DataKeyField="Itemno" EmptyDataText="Data not found" runat="server" AutoGenerateColumns="false" Width="95%
<Columns>
<asp:BoundField DataField="JobCardReference" HeaderText= "JobCardReference" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="JobEntryDate" HeaderText= "JobEntryDate" DataFormatString="{0:d}" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="JCQuantityReceived" HeaderText= "JCQuantityReceived" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Grade" HeaderText= "Grade" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Remarks" HeaderText= "Remarks" HeaderStyle-CssClass="tableHeadTxt" />
</Columns>
</asp:GridView>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>[/code]
Please help me!!!
Thanks!
<
I have not failed. Ive just found 10,000 ways that wont work
<br/>
View the full article
<pre class="prettyprint" style=" Hi , When the Parent GridView dgParent first column image is clicked, the child gridview dgChild is expanding but when the childgridview dgChild first column image is clicked without expanding the next child gridview dgChildChild, it is collapsing back to the parent dgParent. Here Input is InwardNo. <script type="text/javascript
function switchViews(obj, row)
{
var div = document.getElementById(obj);
var img = document.getElementById(img + obj);
if (div.style.display == "none")
{
div.style.display = "inline";
img.src = "../minus.png";
}
else {
div.style.display = "none";
img.src = "../plus.png";
}
}
function switchViews1(obj, row) {
var div = document.getElementById(obj);
var img = document.getElementById(img + obj); if (div.style.display == "none") { div.style.display = "inline";
img.src = "../plus.png";
}
else {
div.style.display = "none";
img.src = "../plus.png";
}
}
</script> [/code]
<pre class="prettyprint" style=" <asp:GridView ID="dgParent" BorderStyle="Solid" GridLines="none" runat="server" DataKeyField="InwardNo" OnRowDataBound="dgParent_RowDataBound" AutoGenerateColumns="False" Width="95%
<Columns>
<asp:TemplateField>
<ItemTemplate>
JavaScript:switchViews(div<%# Eval("InwardNo") %>,one);
<img id="imgdiv<%# Eval("InwardNo") %>" alt="Click to show/hide orders" width="9px" border="0" src="../plus.gif" />
</ItemTemplate>
<AlternatingItemTemplate>
javascript:switchViews(div<%# Eval("InwardNo") %>, alt);
<img id="imgdiv<%# Eval("InwardNo") %>" alt="Click to show/hide orders" border="0" src="../minus.gif" />
</AlternatingItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="InwardNo" HeaderText="InwardNo" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="ReceivedDate" HeaderText="ReceivedDate" DataFormatString="{0:d}" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="LetterNo" HeaderText="LetterNo" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="ConsignmentNo" HeaderText="ConsignmentNo" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Status" HeaderText="Status" HeaderStyle-CssClass="tableHeadTxt" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%
<div id="div<%# Eval("InwardNo") %>" style="display: none; ; >
<asp:GridView ID="dgChild" DataKeyField="InwardNo" GridLines="none" EmptyDataText="Data is not found." OnRowDataBound="dgChild_RowDataBound" runat="server" AutoGenerateColumns="false" Width="95%
<Columns>
<asp:TemplateField ItemStyle-Width="20px
<ItemTemplate>
JavaScript:switchViews1(div<%# Eval("Itemno") %>,one);
<img id="imgdiv<%# Eval("Itemno") %>" alt="Click to show/hide orders" width="9px" border="0" src="../plus.gif" />
</ItemTemplate>
<AlternatingItemTemplate>
javascript:switchViews1(div<%# Eval("Itemno") %>, alt);
<img id="imgdiv<%# Eval("Itemno") %>" alt="Click to show/hide orders" border="0" src="../Plus.gif" />
</AlternatingItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ItemCode" HeaderText= "ItemCode" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="ItemName" HeaderText= "ItemName" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Lab" HeaderText= "Lab" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Itemno" HeaderText="Itemno" Visible="false" HeaderStyle-CssClass="tableHeadTxt" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%
<div id="div<%# Eval("Itemno") %>" style="display: none; ; >
<asp:GridView ID="dgChildChild" DataKeyField="Itemno" EmptyDataText="Data not found" runat="server" AutoGenerateColumns="false" Width="95%
<Columns>
<asp:BoundField DataField="JobCardReference" HeaderText= "JobCardReference" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="JobEntryDate" HeaderText= "JobEntryDate" DataFormatString="{0:d}" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="JCQuantityReceived" HeaderText= "JCQuantityReceived" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Grade" HeaderText= "Grade" HeaderStyle-CssClass="tableHeadTxt" />
<asp:BoundField DataField="Remarks" HeaderText= "Remarks" HeaderStyle-CssClass="tableHeadTxt" />
</Columns>
</asp:GridView>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>[/code]
Please help me!!!
Thanks!
<
I have not failed. Ive just found 10,000 ways that wont work
<br/>
View the full article