hi,
I used the code for gridview within a gridview using jquery functions for expanding and collapsing as shown in article : http://www.aspsnippets.com/Articles/Nested-GridView-Example-in-ASPNet-using-C-and-VBNet.aspx
It works well, but I have textbox in childgrid and it behaves wrongly when i submit childgrid data for saving, it shows character comma (,) before data enetered in textboxes.
I commented all coding for submit button outside both grids, then also on clicking of submit button, there comes comma automatically in textboxes in child grid..
Please guide, I need to use this code urgently.
--------------design------------------
<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");
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "images/plus.png");
$(this).closest("tr").next().remove();
});
</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", "images/minus.png");
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "images/plus.png");
$(this).closest("tr").next().remove();
});
</script>--%>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
.Grid td
{
background-color: #A1DCF2;
color: black;
font-size: 10pt;
line-height: 200%;
}
.Grid th
{
background-color: #3AC0F2;
color: White;
font-size: 10pt;
line-height: 200%;
}
.ChildGrid td
{
background-color: #eee !important;
color: black;
font-size: 10pt;
line-height: 200%;
}
.ChildGrid th
{
background-color: #6C6C6C !important;
color: White;
font-size: 10pt;
line-height: 200%;
}
</style>
<table width="100%">
<tr>
<td>
<asp:Label ID="lblFinYear" runat="server" Text="Financial Year"></asp:Label>
</td>
<td>
<asp:DropDownList CssClass="" ID="dpdFinancialYear" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblDemand" runat="server" Text="Demand No."></asp:Label>
</td>
<td>
<asp:DropDownList CssClass="" ID="dpdDemand" runat="server"
onselectedindexchanged="dpdDemand_SelectedIndexChanged"
AutoPostBack="True">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblTotalTentativeFund" runat="server" Text="Total Tentative Fund :"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtTotalTentativeFund" runat="server" Text=""></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="grdMajorHeads" Width="100%" runat="server" AutoGenerateColumns="false" CssClass="Grid"
DataKeyNames="MajorHeadID_N" OnRowDataBound="grdMajorHeads_RowDataBound">
<Columns>
<asp:BoundField DataField="MajorHeadID_N" HeaderText="Major Head Id"
Visible="false" />
<asp:BoundField DataField="MajorHeadCode_V" HeaderText="Major Head" />
<asp:BoundField DataField="MajorHeadName_V" HeaderText="Major Head Name" />
<asp:TemplateField ItemStyle-HorizontalAlign="Right" HeaderText="Tentaive Fund in Major Head(In Lacs">
<ItemTemplate>
<asp:TextBox ID="txtMajorHeadTentativeFund" CssClass="input_N" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<table><tr><td>
<%--<img alt="" style="cursor: pointer" src="../../Images/plus.png" />--%>
<%--<asp:Panel ID="pnlSchemes" runat="server" style="display:inline" >--%>
<asp:GridView ID="grdSchemes" Width="100%" runat="server" CssClass="ChildGrid"
OnRowDataBound="grdSchemes_RowDataBound" AutoGenerateColumns="false" >
<Columns>
<asp:BoundField DataField="SchemeID_N" Visible="true" />
<asp:BoundField DataField="SchemeCode_V" HeaderText="Scheme" />
<asp:BoundField DataField="SchemeName_V" HeaderText="Scheme Name" />
<asp:TemplateField ItemStyle-HorizontalAlign="Right" HeaderText="Tentaive Fund in Scheme(In Lacs)">
<ItemTemplate>
<asp:TextBox ID="txtSchemeTentativeFund" Text="" AutoCompleteType="None" value="" CssClass="input_N" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<table><tr><td>
<img alt="" style="cursor: pointer" src="../../Images/plus.png" />
<asp:Panel ID="pnlComponents" runat="server" Style="display: none">
<asp:GridView ID="grdComponents" Width="100%" runat="server" AutoGenerateColumns="false" CssClass="Grid" >
<Columns>
<asp:BoundField DataField="MapID_N" Visible="false" />
<%--<asp:BoundField DataField="Code_V" HeaderText="Component/Scheme Type Code" />--%>
<asp:BoundField DataField="Name_V" HeaderText="Component/Scheme Type Name" />
<asp:TemplateField ItemStyle-HorizontalAlign="Right" HeaderText="Tentaive Fund(In Lacs)">
<ItemTemplate>
<asp:TextBox ID="txtCompFundAmount" Text="" CssClass="input_N" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</asp:Panel>
</td></tr></table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<%-- </asp:Panel>--%>
</td></tr></table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnSubmit" Text="Submit Tentative Plan" runat="server" OnClick="btnSubmit_Click" />
</td>
</tr>
</table>