Original Question
http://www.aspforums.net/Threads/135070/ASPNet-Nested-GridView-with-TextBoxes---Unwanted-comma-in-TextBox-after-PostBack/
ASP.Net Nested GridView with TextBoxes - Unwanted comma in TextBox after PostBack
using this code it works but unfortunately with comman in textbox @ postback
<script type="text/javascript">
$("[src*=plus]").live("click", function () {
$(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
$(this).attr("src", "../image/minus.png");
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "../image/plus.png");
$(this).closest("tr").next().remove();
});
</script>
When using the Fix Code to solve the problem. If i click the plus image it doent show the nested grid. Below is the fix code.
<script type="text/javascript">
$("[src*=plus]").live("click", function () {
$(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
$(this).attr("src", "images/minus.png");
$("input", $(this).closest("tr").next()).each(function () {
this.value = this.value.substring(',', '');
});
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "images/plus.png");
$(this).closest("tr").next().remove();
});
</script>
I can show you some of the design.
--------------design------------------
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$("[src*=plus]").live("click", function () {
$(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
$(this).attr("src", "../image/minus.png");
$("input", $(this).closest("tr").next()).each(function () {
this.value = this.value.substring(',', '');
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "../image/plus.png");
$(this).closest("tr").next().remove();
});
</script>
<asp:GridView ID="gvProcessParts1" runat="server" AutoGenerateColumns="False" BackColor="DarkGray"
BorderColor="#999999" BorderWidth="1px" CellPadding="3" DataKeyNames="Structure"
EmptyDataText="EMPTY TABLE" Font-Size="8pt">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="ST">
<ItemTemplate>
<img alt="" style="cursor: pointer" src="../Image/plus.png" height="25" />
<asp:Panel ID="pnlStructure1" runat="server" Style="display: none">
<asp:GridView ID="gvStructure1" runat="server" AutoGenerateColumns="False" BackColor="DarkGray"
BorderColor="#999999" CellPadding="3" DataKeyNames="Structure,ID" EmptyDataText="EMPTY TABLE"
Font-Size="8pt" ShowHeader="False" BorderStyle="None" EnableTheming="False" OnRowCommand="gvStructure1_RowCommand"
OnRowDataBound="gvStructure1_RowDataBound">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="ST">
<ItemTemplate>
<img alt="" style="cursor: pointer" src="../Image/plus.png" height="25" />
<asp:Panel ID="pnlStructure2" runat="server" Style="display: none">
<asp:GridView ID="gvStructure2" runat="server" AutoGenerateColumns="False" BackColor="DarkGray"
BorderColor="#999999" BorderWidth="1px" CellPadding="3" DataKeyNames="Structure"
EmptyDataText="EMPTY TABLE" CaptionAlign="Top" Font-Size="8pt" ShowHeader="False"
OnRowCommand="gvStructure2_RowCommand" OnRowDataBound="gvStructure2_RowDataBound">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="ST">
<ItemTemplate>
<img alt="" style="cursor: pointer" src="../Image/plus.png" height="25" />
<asp:Panel ID="pnlStructure3" runat="server" Style="display: none">
<asp:GridView ID="gvStructure3" runat="server" AutoGenerateColumns="False" BackColor="DarkGray"
BorderColor="#999999" BorderWidth="1px" CellPadding="3" DataKeyNames="Structure"
EmptyDataText="EMPTY TABLE" CaptionAlign="Top" Font-Size="8pt" ShowHeader="False"
OnRowCommand="gvStructure3_RowCommand" OnRowDataBound="gvStructure3_RowDataBound">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="ST">
<ItemTemplate>
<img alt="" style="cursor: pointer" src="../Image/plus.png" height="25" />
<asp:Panel ID="pnlStructure4" runat="server" Style="display: none">
<asp:GridView ID="gvStructure4" runat="server" AutoGenerateColumns="False" BackColor="DarkGray"
BorderColor="#999999" BorderWidth="1px" CellPadding="3" DataKeyNames="Structure"
EmptyDataText="EMPTY TABLE" CaptionAlign="Top" Font-Size="8pt" ShowHeader="False"
OnRowCommand="gvStructure4_RowCommand">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
Please help..