B
bill yeager
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>
<aspataGrid id=Datagrid3 runat="server"
AutoGenerateColumns="False"
DataMember="spMSSASPGetOutstandingConditionsInInvestorRevi
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>
</aspataGrid>
</ItemTemplate>
Thanks so much for your help.........
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>
<aspataGrid id=Datagrid3 runat="server"
AutoGenerateColumns="False"
DataMember="spMSSASPGetOutstandingConditionsInInvestorRevi
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>
</aspataGrid>
</ItemTemplate>
Thanks so much for your help.........