473,385 Members | 2,269 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,385 software developers and data experts.

can't find control in datalist

I have a datagrid control within a datalist control. When
I try and do a "Find" on the control, the object comes
back with nothing and then my pgm crashes. I am 100% sure
that my datagird inside my datalist has an id
of "Datagrid3". dgChild comes back with "Nothing" while
debugging.

Here is my code in the itemdatabound event for the
datalist:
<code>
Private Sub DataList1_ItemDataBound(ByVal sender As
System.Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
DataList2.ItemDataBound

'For each parent record on the datalist, select
the child records that it belongs to
If (e.Item.ItemType = ListItemType.Item) OrElse
(e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim dgChild As DataGrid = DirectCast
(FindControl("DataGrid3"), DataGrid)
dgChild.DataSource = DirectCast
(e.Item.DataItem, DataRowView).CreateChildView
(relBulkConds)
End If

End Sub
</code>

I've been able to find controls before on a datagrid
before, but I havn't tried yet to actually find a
DATAGRID control within a datalist. I know I needed to
make the fields that I am going to access in the datagrid
templatecolumns, but how can I find the DATAGRID control
within my datalist?

Here is my HTML:
<code>
<ItemTemplate>
<asp:label id=Name2 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Name")%>'>
</asp:label>
<asp:RadioButtonList id="Radiobuttonlist2" runat="server"
AutoPostBack="True" RepeatDirection="Horizontal">

<asp:ListItem Value="1">Waive All
Cond</asp:ListItem>

<asp:ListItem Value="0">Don't Waive Any
Conditions</asp:ListItem>

</asp:RadioButtonList>
<asp:DataGrid id=Datagrid3 runat="server"
AutoGenerateColumns="False"
DataMember="spMSSASPGetOutstandingConditionsInInve storRevi
ewStep" DataKeyField="Lock_Number" DataSource="<%#
DsOutstandingCondsInInvestorRvw1 %>" BackColor="White"
BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" GridLines="Vertical">

<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>

<ItemTemplate>

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


</asp:label>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn>

<ItemTemplate>

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

</asp:label>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn>

<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>

Thanks so much for your help.........
Nov 18 '05 #1
1 10893
I figured out how to find the control properly:
<code>
Dim dgChild As DataGrid = e.Item.FindControl("DataGrid3")
</code>

However, during a postback to one of the radio buttons
inside the datalist, I set up and event as follows:
<code>
Protected WithEvents RadioButtonList2 As RadioButtonList
..
..
..
Public Sub rblRadioButtonList2_SelectedIndexChanged(ByVal
sender As Object, ByVal e As System.EventArgs) Handles
RadioButtonList2.SelectedIndexChanged

'Capture the postback event from the
radiobuttonlist
Dim rblConditions As RadioButtonList = DirectCast
(FindControl("RadioButtonList2"), RadioButtonList)
Dim dgChild As DataGrid = DirectCast(FindControl
("DataGrid3"), DataGrid)
Dim chkCondition As CheckBox = DirectCast
(FindControl("Condition3"), CheckBox)
Dim lblLockNumber As Label = DirectCast
(FindControl("LockNumber3"), Label)
Dim lblConditionDetailID As Label = DirectCast
(FindControl("ConditionDetailID3"), Label)
Dim lblLoanID As Label = DirectCast(FindControl
("LoanID3"), Label)
..
..
..
</code>

As it turns out, I can't seem to find any of the controls
like I'm trying above while debugging. The objects all
come back with NOTHING. Why not???

I'm really stumped if someone could please help me.......
-----Original Message-----
I have a datagrid control within a datalist control. WhenI try and do a "Find" on the control, the object comes
back with nothing and then my pgm crashes. I am 100% surethat my datagird inside my datalist has an id
of "Datagrid3". dgChild comes back with "Nothing" while
debugging.

Here is my code in the itemdatabound event for the
datalist:
<code>
Private Sub DataList1_ItemDataBound(ByVal sender As
System.Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs ) Handles
DataList2.ItemDataBound

'For each parent record on the datalist, select
the child records that it belongs to
If (e.Item.ItemType = ListItemType.Item) OrElse
(e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim dgChild As DataGrid = DirectCast
(FindControl("DataGrid3"), DataGrid)
dgChild.DataSource = DirectCast
(e.Item.DataItem, DataRowView).CreateChildView
(relBulkConds)
End If

End Sub
</code>

I've been able to find controls before on a datagrid
before, but I havn't tried yet to actually find a
DATAGRID control within a datalist. I know I needed to
make the fields that I am going to access in the datagridtemplatecolumns, but how can I find the DATAGRID control
within my datalist?

Here is my HTML:
<code>
<ItemTemplate>
<asp:label id=Name2 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Name")%>'>
</asp:label>
<asp:RadioButtonList id="Radiobuttonlist2" runat="server"AutoPostBack="True" RepeatDirection="Horizontal">

<asp:ListItem Value="1">Waive All
Cond</asp:ListItem>

<asp:ListItem Value="0">Don't Waive Any
Conditions</asp:ListItem>

</asp:RadioButtonList>
<asp:DataGrid id=Datagrid3 runat="server"
AutoGenerateColumns="False"
DataMember="spMSSASPGetOutstandingConditionsInInv estorRev iewStep" DataKeyField="Lock_Number" DataSource="<%#
DsOutstandingCondsInInvestorRvw1 %>" BackColor="White"
BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" GridLines="Vertical">

<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>

<ItemTemplate>

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


</asp:label>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn>

<ItemTemplate>

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

</asp:label>

</ItemTemplate>

</asp:TemplateColumn>

<asp:TemplateColumn>

<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>

Thanks so much for your help.........
.

Nov 18 '05 #2

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

Similar topics

1
by: bid | last post by:
I have 2 controls on this page as shown below. The first is a datalist control which contains links to the particular image gallery (second control) I want to display. However I only want the...
0
by: ani | last post by:
I have few questions regarding datalist control. 1) How do I retrieve the values that are present in the datalist control. My aspx page actually reloads to itself, and the datalist control has...
8
by: Nevyn Twyll | last post by:
I have a multi-level datalist setup: DataList1 DataList2 MyGrid I have columns explicitly defined for the grid in the html. Sometimes, On the initial Load() of the Page, I want to add extra...
1
by: Mike | last post by:
I've been banging my head on this for days and can't get it working. If i can't get it by today then i'm done with it. I have a datalist that has a table in it <asp:datalist id=dl1>...
2
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the...
6
by: Davids | last post by:
having a 100% working aspx page I wanted to create a user control from a small DataList section (which has an ID="DataList1") of the page, so I created an ascx file with the DataList and Register...
1
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
1
by: Salim | last post by:
Hi, I'm trying to get UniqueID of a linkbutton. I have 2 web user controls. And a master page. In fisrst web user control there is a datalist. In datalist ItemCreated event, I try to find...
1
by: Sripelly | last post by:
I am using a Datalist control which contains 4 lables,2 textboxes,..etc. How to find the label in the Datalist control
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.