[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 616
  • Last Modified:

findcontrol method

Hi friends, this is really simple, I basically have the same problem as this guy( see http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_21127046.html?query=nested+datagrid&clearTAFilter=true)

Am gona use his soln to try and solve mine.

My question is-- why is the "dgDetails" referred to as cell(9) i can figure it out???.  thanks

Private Sub dgMaster_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgMaster.ItemDataBound
Dim drv As DataRowView = e.Item.DataItem
Dim dgChild As DataGrid = e.Item.Cells(9).FindControl("dgDetails")
dgChild.DataSource = drv.CreateChildView("ID")
dgChild.DataBind()
End Sub
-------------------------------------------------
i have counted these controls from zero on wards, cant figure out why its cell(9)

<asp:datagrid id="dgMaster" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 56px" runat="server"
Visible="False" AllowSorting="True" AllowPaging="True" PageSize="25" Width="576px" ShowFooter="True" AutoGenerateColumns="False" OnEditCommand="ShowDetails">
<Columns>
<asp:BoundColumn DataField="id" ReadOnly="True" HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="Part#" ReadOnly="True" HeaderText="Part #"></asp:BoundColumn>
<asp:BoundColumn DataField="SerialNum" ReadOnly="True" HeaderText="SerialNum"></asp:BoundColumn>
<asp:BoundColumn DataField="WorkOrder" ReadOnly="True" HeaderText="WorkOrder"></asp:BoundColumn>
<asp:BoundColumn DataField="Batch#" ReadOnly="True" HeaderText="Batch#"></asp:BoundColumn>
<asp:BoundColumn DataField="Description" ReadOnly="True" HeaderText="Description"></asp:BoundColumn>
<asp:BoundColumn DataField="Pass/Fail?" ReadOnly="True" HeaderText="Pass/Fail?"></asp:BoundColumn>
<asp:BoundColumn DataField="NumofFreqsTestedAt" ReadOnly="True" HeaderText="NumofGregTestedAt"></asp:BoundColumn>
<asp:BoundColumn DataField="NewStartTime" ReadOnly="True" HeaderText="NewStartTime"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton runat="server" Text="Show Details" CommandName="Edit" CausesValidation="false"></asp:LinkButton>
</ItemTemplate>
<EditItemTemplate>
<asp:DataGrid id="dgDetails" runat="server" ShowHeader="True">
<Columns>
<asp:BoundColumn DataField="field_name" HeaderText="Field Name"></asp:BoundColumn>
<asp:BoundColumn DataField="item_data" HeaderText="Data"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
0
SirReadAlot
Asked:
SirReadAlot
1 Solution
 
Rodney HelsensCommented:
The datagrid has 8 BoundColumns, followed by one TemplateColumn #9, because the index starts at zero.

The template column has two options the ItemTemplate, and the EditItemTemplate, these are both referred to as cell (9) because they are mutually exclusive, either one of the other will be rendered, but not both at the same time.


0
 
SirReadAlotAuthor Commented:
AM I RIGHT TO INSERT MY INNER GRID INSIDE THE <ITEMTEMPLATE> TAG? SEE CODE
==========================
<asp:datagrid id="dgRoles" Runat="server" Height="75px" Width="297px" AutoGenerateColumns="False"      BorderWidth="2px" DataKeyField="RoleID" BorderColor="black" CellPadding="3" GridLines="Both" AlternatingItemStyle-BackColor="#eeeeee"HeaderStyle-BackColor="#ff8040" Font-Size="8pt" Font-Name="Verdana" OnEditCommand="OnEdit" OnCancelCommand="Oncancel"      OnUpdateCommand="OnUpdate">
<Columns>
<asp:TemplateColumn HeaderText="Roles">
<ItemTemplate>
<asp:Label text='<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"Role"))%>' Runat="server" ID="lblRoles"/>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox Runat="server" ID="txtRole" Text='<%# Convert.ToString(DataBinder.Eval(Container.DataItem,"Role"))%>' Width="150"/>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Delete">
<ItemTemplate>
<asp:CheckBox ID="chkSelection" Enabled="true" runat="server" />
<asp:Label ID="RoleDelete" Visible="False" Text='<%# DataBinder.Eval(Container.DataItem, "RoleID") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update"></asp:EditCommandColumn>
<asp:TemplateColumn HeaderText="Sections">
<ItemTemplate>
<!-- NEW DATAGRID IN HERE -->
<asp:DataGrid ID="dgNewSection" Runat="server" BorderStyle="None" BorderWidth="0" CellPadding="3" CellSpacing="0" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="SectionName" HeaderText="Section Name"></asp:BoundColumn>                              </Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></td>
</tr>
            
===========================
am asking b/c the other soln did not do the same
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now