cannot find some controls in a datalist

W

William Yeager

I have a datalist displaying parent information and a datagrid
presenting child information. The data is being rendered just fine. The
datagrid has template columns on it that I cannot gain access to in my
Itemcommand event of the datalist.

When I press a button on the datalist, that brings me into the
Itemcommand event. I have access to the datagrid control, but not any
column controls on the datagrid. For instance, my first column is a
checkbox with an ID of "Condition3" that I can't find. While debugging,
I have cycled thru the control items of the Datalist, and cannot find
any of the columns inside my datagrid (which is inside my datalist).

Here is ItemTemplate portion of my Datalist with the HTML:


<ItemTemplate>

<asp:label id=Name2 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Name")%>'>

</asp:label>

<asp:label id=LockNumber2 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Lock_Number")%>'>

</asp:label>

<asp:label id=LoanID2 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.LoanID")%>' Visible="False">

</asp:label>

<p>

<asp:Button id="btnWaive" runat="server" Text="Waive All
Conditions" CommandName="Waive"></asp:Button>&nbsp;&nbsp;&nbsp;&nbsp;

<asp:Button id="btnNoWaive" runat="server" Text="Don't Waive Any
Condtions" CommandName="NoWaive"></asp:Button></p>

<asp:DataGrid id=Datagrid3 runat="server"
AutoGenerateColumns="False" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical" datasource='<%#
Container.DataItem.CreateChildView("spMSSASPGetDistinctOutstandingCondit
ionsInInvestorReviewStepspMSSASPGetOutstandingConditionsInInvestorReview
Step")%>'>

<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>

<AlternatingItemStyle
BackColor="Gainsboro"></AlternatingItemStyle>

<ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>

<HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#000084"></HeaderStyle>

<FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>

<Columns>

<asp:TemplateColumn>

<ItemTemplate>

<asp:checkbox runat="server" id="Condition3"></asp:checkbox>

</ItemTemplate>

</asp:TemplateColumn>

<asp:BoundColumn DataField="Name" ReadOnly="True"
HeaderText="Name"></asp:BoundColumn>

<asp:TemplateColumn HeaderText="LoanID">

<ItemTemplate>

<asp:label runat="server" id="LoanID3" Text='<%#
DataBinder.Eval(Container, "DataItem.LoanID") %>'>

</asp:label>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Lock Number">

<ItemTemplate>

<asp:label runat="server" id="LockNumber3" Text='<%#
DataBinder.Eval(Container, "DataItem.Lock_Number") %>'>

</asp:label>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Conditional Dtl ID">

<ItemTemplate>

<asp:label runat="server" id="ConditionDetailID3" Text='<%#
DataBinder.Eval(Container, "DataItem.ConditionDetailID") %>'>

</asp:label>

</ItemTemplate>

</asp:TemplateColumn>

<asp:BoundColumn DataField="ConditionID" ReadOnly="True"
HeaderText="ConditionID"></asp:BoundColumn>

<asp:BoundColumn DataField="Description" ReadOnly="True"
HeaderText="Description"></asp:BoundColumn>

<asp:BoundColumn DataField="Comment" ReadOnly="True"
HeaderText="Comment"></asp:BoundColumn>

</Columns>

<PagerStyle HorizontalAlign="Center" ForeColor="Black"
BackColor="#999999" Mode="NumericPages"></PagerStyle>

</asp:DataGrid>

</ItemTemplate>




Here is the code-behind where I'm trying to access the checkbox:


Private Sub DataList2_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs) Handles
DataList2.ItemCommand



Dim dgChild As DataGrid = e.Item.FindControl("DataGrid3")

Dim chkCondition As CheckBox = e.Item.FindControl("Condition3")

..

..

..




In the first line above, I gain access to my datagird. However, the next
line, I don't have any access to my columns within my datagrid.

How can I gain access to these column controls within my datagrid???
 
C

CJ Smit

Any luck on this issue ? I have almost the same problem. Cannot find dynamically built controls in datagrid
 
W

William Yeager

CJ, I don't have a solution yet. If I get one, I'll post it. Please do
the same for me.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top