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>
SirReadAlotAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.