Hello Brad,
From the code snippet you provided, your Findcontrol code should be ok, the
problem here is likely due to the place where you call the FindControl and
databinding code. Actually, you put the Repeater control in the FormView's
EditTemplate, that means only when the FormView is in edit mode will you be
able to access the Repeater control(or any other sub controls in the edit
template).
Also, since this databinding customization code logic is more specific to
the FormView control, it is better to put them in FormView's event handler
and the "ItemCreated" event is a good place to handle our customization on
the FormView's Row or its child controls.
#FormView.ItemCreated Event
http://msdn2.microsoft.com/en-us/lib...trols.formview.
itemcreated.aspx
Here is my modified test FormView and code behind code, you can test them
on your side for reference:
============FormView template=============
<asp:FormView ID="FormView1" runat="server"
DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"
OnItemCreated="FormView1_ItemCreated">
<EditItemTemplate>
CategoryID:
<asp:Label ID="CategoryIDLabel1" runat="server" Text='<%#
Eval("CategoryID") %>'></asp:Label><br />
CategoryName:
<asp:TextBox ID="CategoryNameTextBox" runat="server"
Text='<%# Bind("CategoryName") %>'></asp:TextBox><br />
<br /><hr /><br />
<table class="tableborder">
<tr>
<td colspan="4">
<asp:Repeater ID="tabs_repeater" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<%# Container.DataItem %>
</ItemTemplate>
<FooterTemplate>
<td>
<h2>
Customer Configuration</h2>
</td>
</tr></table>
</FooterTemplate>
</asp:Repeater>
</td>
</tr>
</table>
<br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
...............................
</InsertItemTemplate>
<ItemTemplate>
.........................
</ItemTemplate>
</asp:FormView>
========================================
In "ItemCreaetd" event, we do the databinding for the repeater control:
========code behind event handler==========
protected void FormView1_ItemCreated(object sender, EventArgs e)
{
if (FormView1.CurrentMode == FormViewMode.Edit)
{
string[] items = new string[] { "aaa","bbb","ccc","ddd"};
Repeater rpt = FormView1.Row.FindControl("tabs_repeater") as
Repeater;
if (rpt != null)
{
rpt.DataSource = items;
rpt.DataBind();
}
}
}
=============================
Please feel free to let me know if you have anything unclear or any further
questions on this.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.