G
Guest
I have what's probably a simple page lifecycle question related to
dynamically evaluating values that are placed by a repeater and dynmically
placing user controls that use those values.
I'm attempting to bind a user control I've written, "ImageBox", to a
repeater.
The user control takes a custom property, "ContentID", that will execute a
database lookup and load an image.
I am attempting to do those lookups based on the dynamic evaluation of
values that are placed from a SqlDataSource into the repeater:
<asp:SqlDataSource SelectCommand="Select Top (5)...
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="NewsReleasesWithIcons" OnInit="Prerendering">
....
<ItemTemplate>
<uc1:Uwn_ImageBox ID="Uwn_ImageBox1" runat="server" ImageWidth="200"
ContentID='<%# Eval("Con_ConRelTo") %>' />
</ItemTemplate>
If the ContentID were passed from the repeater to the ImageBox control and
evaluated, the control would be dynamically generated. I have tested this
works by substituting a static value for the value I am trying to evalate: I
get my image control loaded and repeated five times.
The code above does not do what I intend: looking at the debugger, the
ContentID does not get passed to the UserControl "in time" -- on the first
iteration of the repeater, the ContentID is set to zero, rather than the
values that [will] come out of SqlDataSource. The evalution of <%#
Eval("Con_ConRelTo") %> does not happen before the repeater attempts to
instantiate my user control.
Is there a simple way to address this problem? One way or another, I need
the following sequence
1) Database lookup for a collection of ContentIDs (this is what I was
attempting to use SqlDataSource todo)
2) Binding the ContentIDs found in step 1 to a repeater, one for each item
3) Repeater calls User controls and passes them my ContentIDs
4) User controls do their own DB lookups, and place cutlines, images, etc.
Thank you,
-KF
dynamically evaluating values that are placed by a repeater and dynmically
placing user controls that use those values.
I'm attempting to bind a user control I've written, "ImageBox", to a
repeater.
The user control takes a custom property, "ContentID", that will execute a
database lookup and load an image.
I am attempting to do those lookups based on the dynamic evaluation of
values that are placed from a SqlDataSource into the repeater:
<asp:SqlDataSource SelectCommand="Select Top (5)...
<asp:Repeater ID="Repeater1" runat="server"
DataSourceID="NewsReleasesWithIcons" OnInit="Prerendering">
....
<ItemTemplate>
<uc1:Uwn_ImageBox ID="Uwn_ImageBox1" runat="server" ImageWidth="200"
ContentID='<%# Eval("Con_ConRelTo") %>' />
</ItemTemplate>
If the ContentID were passed from the repeater to the ImageBox control and
evaluated, the control would be dynamically generated. I have tested this
works by substituting a static value for the value I am trying to evalate: I
get my image control loaded and repeated five times.
The code above does not do what I intend: looking at the debugger, the
ContentID does not get passed to the UserControl "in time" -- on the first
iteration of the repeater, the ContentID is set to zero, rather than the
values that [will] come out of SqlDataSource. The evalution of <%#
Eval("Con_ConRelTo") %> does not happen before the repeater attempts to
instantiate my user control.
Is there a simple way to address this problem? One way or another, I need
the following sequence
1) Database lookup for a collection of ContentIDs (this is what I was
attempting to use SqlDataSource todo)
2) Binding the ContentIDs found in step 1 to a repeater, one for each item
3) Repeater calls User controls and passes them my ContentIDs
4) User controls do their own DB lookups, and place cutlines, images, etc.
Thank you,
-KF