please help How to change readonly textboxes inside nested gridview.
I want to change them when I click the Plus (+) image to expand the nested gridview.
What we add on this code below
<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");
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "../image/plus.png");
$(this).closest("tr").next().remove();
});
</script>
ASP code
<asp:GridView ID="gvStructure0" 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="gvStructure_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="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="gvStructure_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="gvStructure_RowCommand" OnRowDataBound="gvStructure2_RowDataBound">
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<Columns>
<asp:TemplateField HeaderText="RemQty" SortExpression="RemainingQty">
<ItemTemplate>
<asp:TextBox ID="txtRemQty" runat="server" Readonly = "True" BackColor="Transparent" BorderStyle="None"
Font-Size="8pt" Style="text-align: center" Text='<%# Bind("RemainingQty") %>'
Width="50px" Font-Bold="True" ForeColor="#C000C0"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ReqdQty" SortExpression="RequiredQty">
<ItemTemplate>
<asp:TextBox ID="txtReqdQty" runat="server" Readonly = "True" BackColor="Transparent" BorderStyle="None"
Font-Size="8pt" Style="text-align: center" Text='<%# Bind("RequiredQty") %>'
Width="50px" Font-Bold="True" ForeColor="Green"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ReqtQty" SortExpression="RequestedQty">
<ItemTemplate>
<asp:TextBox ID="txtReqtQty" runat="server" Readonly = "True" BackColor="Transparent" BorderStyle="None"
Font-Size="11pt" Style="text-align: center" Text='<%# Bind("RequestedQty") %>'
Width="50px" Font-Bold="True" ForeColor="#C00000"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Transparent" Wrap="True" BorderStyle="None" />
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="RemQty" SortExpression="RemainingQty">
<ItemTemplate>
<asp:TextBox ID="txtRemQty" runat="server" Readonly = "True" BackColor="Transparent"
Font-Size="8pt" Style="text-align: center" Text='<%# Bind("RemainingQty") %>'
Width="50px" BorderStyle="None" Font-Bold="True" ForeColor="#C000C0" ToolTip="Remaining Quantity"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ReqdQty" SortExpression="RequiredQty">
<ItemTemplate>
<asp:TextBox ID="txtReqdQty" runat="server" Readonly = "True" BackColor="Transparent" BorderStyle="None"
Font-Size="8pt" Style="text-align: center" Text='<%# Bind("RequiredQty") %>'
Width="50px" Font-Bold="True" ForeColor="Green" Height="12px" ToolTip="Required Quantity"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ReqtQty" SortExpression="RequestedQty">
<ItemTemplate>
<asp:TextBox ID="txtReqtQty" runat="server" Readonly = "True" BackColor="Transparent" BorderStyle="None"
Font-Size="11pt" Style="text-align: center" Text='<%# Bind("RequestedQty") %>'
Width="50px" Font-Bold="True" ForeColor="#C00000" ToolTip="Requested Quantity"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Transparent" Wrap="True" />
</asp:GridView>
VB Code
Protected Sub gvStructure0_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvStructure0.DataBound
'***************this might not have function please check
'Find Out if gvProcessParts has data or not
Dim rowCount As Integer = gvStructure0.Rows.Count ' returns zero
If rowCount.ToString <> 0 Then
DLJobNo.DataSource = GetData("select DISTINCT [JobNo] From [ProcessPartsJobNo] ORDER BY JobNo DESC")
DLJobNo.DataTextField = "JobNo"
DLJobNo.DataBind()
DLJobNo.Text = Session("JobNoMem")
'SHOW Build Button
LBBuilt.Visible = False
End If
End Sub
Protected Sub gvStructure0_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvStructure0.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then 'Used to Loop all rows
Dim StructureParent As String = gvStructure0.DataKeys(e.Row.RowIndex).Value.ToString() 'Value of datakey inside the databound or Selected row
StructureParent = StructureParent + "."
'Find gvStructure1 and populate
Dim gvStructure1 As GridView = TryCast(e.Row.FindControl("gvStructure1"), GridView)
gvStructure1.DataSource = GetData("select * From [ProcessPartsJobNo] where [JobNo]=" + Session("JobNoMem") + " and ([Structure] Like '" + StructureParent + "[0-99]' or [Structure] Like '" + StructureParent + "[0-9][0-9]')")
gvStructure1.DataBind()
End If
End Sub
Thank you