473,241 Members | 1,579 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,241 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 10883
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.