473,387 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

can't gain access to controls

I did some more debugging and found the following:

1) I placed the following code in the button event just
to see if I could cycle thru the datagrid control
collection:
<code>
Dim strhello As String
Dim myDataListItem As DataListItem
Dim myDatagridItem As DataGridItem
Dim myCheckBox As CheckBox
Dim myDataGrid As DataGrid

For Each myDataListItem In DataList2.Items
myDataGrid = myDataListItem.FindControl
("DataGrid3")
If Not IsNothing(myDataGrid) Then
For Each myDatagridItem In
myDataGrid.Items
myCheckBox = myDataGrid.FindControl
("Condition3")
If myCheckBox.Checked Then
strhello = "found!"
'do any processing that is needed
End If
Next
End If
Next
</code>

2) The line "For Each myDatagridItem In myDataGrid.Items"
produces the following:
- myDataGrid.Items.Count yields 4 (which is
correct since there are 4 rows in this child grid)
- myDatagridItem.Controls.Count yields 8 (which
is correct because there are 8 column controls).
According to this statement, I should be able to access
the columns inside this child grid.
- However, the statement "myCheckBox =
myDataGrid.FindControl("Condition3")" yields NOTHING... I
can't access any of the column controls inside this child
datagrid!

3) I'm able to get a listing on each of the items inside
this datagrid from item 0 to 7 as follows:
myDatagridItem.Controls.Item(7)
{System.Web.UI.WebControls.TableCell}
[System.Web.UI.WebControls.TableCell]:
{System.Web.UI.WebControls.TableCell}
BindingContainer:
{System.Web.UI.WebControls.DataGridItem}
ClientID: "DataList2__ctl1_Datagrid3__ctl2__ctl1"
Controls: {System.Web.UI.ControlCollection}
EnableViewState: True
ID: Nothing
NamingContainer:
{System.Web.UI.WebControls.DataGridItem}
Page: {ASP.BulkConditions_aspx}
Parent: {System.Web.UI.WebControls.DataGridItem}
Site: Nothing
TemplateSourceDirectory: "/LydianMDS"
UniqueID: "DataList2:_ctl1:Datagrid3:_ctl2:_ctl1"
Visible: True

Notice the ID above. EACH OF THESE ITEMS IS SET TO
NOTHING! That is the reason why I can't access the
controls in code..........

OK now... Since I have debugged this issue, I'm hoping
someone will be able to tell me WHY THOSE ITEMS HAVE AN
ID OF NOTHING... I'm expecting to find these items
programatcially, but can't. In my HTML below, you can
plainly see that the template columns have an ID
associated with them.

The following is the HTML of my entire datalist (parent)
and datagrid (child) controls.
<code>
<asp:DataList id=DataList2 style="Z-INDEX: 105; LEFT:
8px; POSITION: absolute; TOP: 192px" runat="server"
DataMember="spMSSASPGetDistinctOutstandingConditio nsInInve
storReviewStep" DataKeyField="Lock_Number" DataSource="<%
# DsOutstandingCondsInInvestorRvw1 %>" Width="936px"
BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical" Height="544px">
<SelectedItemStyle Font-
Bold="True" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>
<HeaderTemplate>
<P>Outstanding
BULK Conditions</P>
</HeaderTemplate>
<AlternatingItemStyle
BackColor="Gainsboro"></AlternatingItemStyle>
<FooterTemplate>
NO MORE
OUTSTANDING CONDITIONS
</FooterTemplate>
<ItemStyle
ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
<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
("spMSSASPGetDistinctOutstandingConditionsInInvest orReview
StepspMSSASPGetOutstandingConditionsInInvestorRevi ewStep")
%>'>

<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>
<FooterStyle
ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
<SeparatorTemplate>
------------------
----------------------------------------------------------
----------------------------------------------------------
--------------------
</SeparatorTemplate>
<HeaderStyle Font-
Bold="True" ForeColor="White"
BackColor="#000084"></HeaderStyle>
</asp:DataList>
</code>

Can someone PLEASE HELP ME WITH THIS. I have gone as FAR
AS I can go with it. I'm totally stuck at this point...

Why do those controls in the datagrid have an ID of
NOTHING (thereby not allowing me to access those
controls)...

Thanks,

Bill
Nov 18 '05 #1
1 1735
The problem was that I wasn't doing the findcontrol
method down on the proper child control level!!! By
looping thru the following code, and playing around, I
was able to gain access to the child controls inside the
datagrid....

For all to see and share:
<code>
Dim myDataListItem As DataListItem
Dim myDatagridItem As DataGridItem
Dim myDataGrid As DataGrid
Dim myCheckBox As CheckBox
Dim lblLockNumber As Label
Dim lblConditionDetailID As Label
Dim lblLoanID As Label
Dim i As Int16

Try
For Each myDataListItem In DataList2.Items
myDataGrid = myDataListItem.FindControl
("DataGrid3")
If Not IsNothing(myDataGrid) Then
i = 0
For Each myDatagridItem In
myDataGrid.Items
myCheckBox =
myDatagridItem.Controls.Item(i).FindControl("Condi tion3")
If myCheckBox.Checked Then
lblLockNumber =
myDatagridItem.Controls.Item(i).FindControl("LockN umber3")
lblConditionDetailID =
myDatagridItem.Controls.Item(i).FindControl
("ConditionDetailID3")
lblLoanID =
myDatagridItem.Controls.Item(i).FindControl("LoanI D3")
Dim drSave As
dsSaveCondition.dsSaveConditionRow =
DsSaveCondition1.dsSaveCondition.NewdsSaveConditio nRow
drSave.Lock_Number =
lblLockNumber.Text
drSave.ConditionDetailID =
lblConditionDetailID.Text
drSave.LoanID = lblLoanID.Text

DsSaveCondition1.dsSaveCondition.Rows.Add(drSave)
End If
i += 1
Next
End If
Next
Catch ex As Exception
m_blnError = True
Response.Write("<script>alert('" & ex.Message
& "');</script>")
End Try
</code>
-----Original Message-----
I did some more debugging and found the following:

1) I placed the following code in the button event just
to see if I could cycle thru the datagrid control
collection:
<code>
Dim strhello As String
Dim myDataListItem As DataListItem
Dim myDatagridItem As DataGridItem
Dim myCheckBox As CheckBox
Dim myDataGrid As DataGrid

For Each myDataListItem In DataList2.Items
myDataGrid = myDataListItem.FindControl
("DataGrid3")
If Not IsNothing(myDataGrid) Then
For Each myDatagridItem In
myDataGrid.Items
myCheckBox = myDataGrid.FindControl
("Condition3")
If myCheckBox.Checked Then
strhello = "found!"
'do any processing that is needed End If
Next
End If
Next
</code>

2) The line "For Each myDatagridItem In myDataGrid.Items"produces the following:
- myDataGrid.Items.Count yields 4 (which is
correct since there are 4 rows in this child grid)
- myDatagridItem.Controls.Count yields 8 (which
is correct because there are 8 column controls).
According to this statement, I should be able to access
the columns inside this child grid.
- However, the statement "myCheckBox =
myDataGrid.FindControl("Condition3")" yields NOTHING... Ican't access any of the column controls inside this childdatagrid!

3) I'm able to get a listing on each of the items inside
this datagrid from item 0 to 7 as follows:
myDatagridItem.Controls.Item(7)
{System.Web.UI.WebControls.TableCell}
[System.Web.UI.WebControls.TableCell]:
{System.Web.UI.WebControls.TableCell}
BindingContainer:
{System.Web.UI.WebControls.DataGridItem}
ClientID: "DataList2__ctl1_Datagrid3__ctl2__ctl1"
Controls: {System.Web.UI.ControlCollection}
EnableViewState: True
ID: Nothing
NamingContainer:
{System.Web.UI.WebControls.DataGridItem}
Page: {ASP.BulkConditions_aspx}
Parent: {System.Web.UI.WebControls.DataGridItem}
Site: Nothing
TemplateSourceDirectory: "/LydianMDS"
UniqueID: "DataList2:_ctl1:Datagrid3:_ctl2:_ctl1"
Visible: True

Notice the ID above. EACH OF THESE ITEMS IS SET TO
NOTHING! That is the reason why I can't access the
controls in code..........

OK now... Since I have debugged this issue, I'm hoping
someone will be able to tell me WHY THOSE ITEMS HAVE AN
ID OF NOTHING... I'm expecting to find these items
programatcially, but can't. In my HTML below, you can
plainly see that the template columns have an ID
associated with them.

The following is the HTML of my entire datalist (parent)
and datagrid (child) controls.
<code>
<asp:DataList id=DataList2 style="Z-INDEX: 105; LEFT:
8px; POSITION: absolute; TOP: 192px" runat="server"
DataMember="spMSSASPGetDistinctOutstandingConditi onsInInv estorReviewStep" DataKeyField="Lock_Number" DataSource="<%
# DsOutstandingCondsInInvestorRvw1 %>" Width="936px"
BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3"
GridLines="Vertical" Height="544px">
<SelectedItemStyle Font-
Bold="True" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>
<HeaderTemplate>
<P>Outstanding
BULK Conditions</P>
</HeaderTemplate>
<AlternatingItemStyle
BackColor="Gainsboro"></AlternatingItemStyle>
<FooterTemplate>
NO MORE
OUTSTANDING CONDITIONS
</FooterTemplate>
<ItemStyle
ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
<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>

<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
("spMSSASPGetDistinctOutstandingConditionsInInvest orReviewStepspMSSASPGetOutstandingConditionsInInvestorRev iewStep" )%>'>

<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>
<FooterStyle
ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
<SeparatorTemplate>
------------------
---------------------------------------------------------

---------------------------------------------------------- ---------------------
</SeparatorTemplate>
<HeaderStyle Font-
Bold="True" ForeColor="White"
BackColor="#000084"></HeaderStyle>
</asp:DataList>
</code>

Can someone PLEASE HELP ME WITH THIS. I have gone as FAR
AS I can go with it. I'm totally stuck at this point...

Why do those controls in the datagrid have an ID of
NOTHING (thereby not allowing me to access those
controls)...

Thanks,

Bill
.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Roy Gourgi | last post by:
Hi, I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than...
4
by: Jim Bancroft | last post by:
Hi everyone, I have an ASP.Net page that uses various DataGrids and other ASP controls. Right now I'm manipulating them in my code-behind file, but I'd like to use my business-logic dlls for...
8
by: carriolan | last post by:
Hi I have an MS Access based application almost ready for distribution to the public and I find that even though I have compiled it into an MDE file, tables and queries can still be be imported if...
7
by: phillip.s.powell | last post by:
We're looking at a GUI interface for our MySQL DB and I am interested in MySQL Administrator, however, one of our requirements is to be able to import/export databases. Is this possible or do I...
4
by: aurora10 | last post by:
Can ant body help me to see how to get access to all controls of the Form for Sub in a different class. Thanks in advance. this is how it looks: ////////////////////////////////////////...
8
by: Claus | last post by:
Hi all, I am new to C#, .NET and Visual Studio but I have been coding professionally for more than 10 years, so I am not a complete newbe :-) At my work we are now in the process of switching...
1
by: googlegroup | last post by:
I have master pages , with MyAccordion and 2 panes. I can veiw the controls within MyAccordion on pageLoad Output of controls: MyAccordion_AccordionExtender AccordionPane1 AccordionPane2
3
by: freeskier | last post by:
hello, i have a split ms access database with front ends distributed to several users. it is a real pain to have to wait until everyone signs off for the day to make design changes to the backend....
17
by: Blau | last post by:
I'm trying to use the System.Windows.Controls namespace, but when I try to add a reference to it I don't see it in the list. I see a System.Windows.Forms, but not a System.Windows.Controls. Can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.