Hi Steven,
Actually, I am creating the ArrayList in the CodeBehind and then trying to
bind the FormView Control to it. The ASPX text for the FormView
(<EditItemTempl ate>) is at the bottom.
CodeBehind File
-----------------
Protected Sub fvCustRev_PreRe nder(ByVal sender As Object, ByVal e As
EventArgs) Handles fvCustRev.PreRe nder
If Me.fvCustRev.Cu rrentMode = FormViewMode.Ed it Then
Me.hdnPresentMo de.Value = "fvCustRev.Edit "
Call Me.YearLoop()
End If
End Sub
Private Sub YearLoop()
'Use Array to build DropDownList with For Loop
ctrFor = 0
Dim arrFor As ArrayList = New ArrayList()
For ctrFor = Year(Now()) - 3 To Year(Now()) + 10
arrFor.Add(ctrF or)
Next
arrFor.TrimToSi ze()
'Assign list to FormView datacontrol
If Me.hdnPresentMo de.Value = "fvCustRev.Edit " Then
CType(Me.fvCust Rev.FindControl ("ddlRevenueYea rEdit"),
DropDownList).D ataSource = arrFor
CType(Me.fvCust Rev.FindControl ("ddlRevenueYea rEdit"),
DropDownList).D ataBind()
End If
End Sub
Here is the FormView for the <EditTemplate >
-----------------------------------------------
<asp:FormView
ID="fvCustRev"
runat="server"
DataKeyNames="C ustomerRevenue_ ID"
DataSourceID="d sDetail"
OnItemUpdating= "fvCustRev_Item Updating_Valida te"
OnItemUpdated=" fvCustRev_ItemU pdated_Trans"
OnItemInserting ="fvCustRev_Ite mInserting_Vali date"
DefaultMode="Ed it"
style="width:70 %">
<EditItemTempla te>
<table class="tblOutli ne" style="width:10 0%" border="1px">
<tr>
<th colspan="2"><as p:Label ID="lblTitleEdi t" Text="Customer Revenue:
Edit" runat="server" /></th>
</tr>
<tr>
<td style="width:30 %; text-align:right;" class="BlkB">Re venue
Year: </td>
<td style="width:70 %; text-align:left;">
<asp:DropDownLi st id="ddlRevenueY earEdit" Runat="Server"
DataTextField=" CategoryType_ID " DataValueField= "CategoryType_I D"
SelectedValue=' <%# Bind("RevenueYe ar") %>'/></td>
</tr>
<tr>
<td style="width:30 %; text-align:right;"
class="BlkB">Cu stomer: </td>
<td style="width:70 %; text-align:left;">
<asp:TextBox ID="txtCustomer Edit" Text='<%# Bind("Customer" ) %>'
Width="200px" runat="server" /></td>
</tr>
<tr>
<td style="width:30 %; text-align:right;" class="BlkB">Re gion: </td>
<td style="width:70 %; text-align:left;">
<asp:DropDownLi st id="ddlRegionEd it" DataSourceID="d sRegionDLL"
Runat="Server"
DataTextField=" CategoryType_ID " DataValueField= "CategoryType_I D"
SelectedValue=' <%# Bind("Region") %>'/></td>
</tr>
<tr>
<td style="width:30 %; text-align:right;" class="BlkB">An nual
Rev: </td>
<td style="width:70 %; text-align:left;">
<asp:TextBox ID="txtAnnualRe venueEdit" Text='<%# Bind("AnnualRev enue",
"{0:c0}") %>' Width="100px" runat="server" /></td>
</tr>
<tr>
<td colspan="2">
<br />
&nb sp;
<asp:LinkButt on ID="UpdateButto n" runat="server"
CausesValidatio n="True" CommandName="Up date" Text="Update" />
&nb sp;
<asp:LinkButt on ID="UpdateCance lButton" runat="server"
CausesValidatio n="False" CommandName="Ca ncel" Text="Cancel" /></td>
</tr>
</table><br />
</EditItemTemplat e>
"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:cx******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hi Sck10,
Thank you for posting.
From your description, you're encountering some exception when try to
dynamically bind an ArrayList to the DropDownList control(in a formview?).
As for the FormView and dropdownlist, would you provide the complete page
markup (aspx) so that we can get the complete view of the two controls and
their relation ship. Also, as for intercept the dropdownlist and perform
further databinding, you can use the FormView's "DataBound" event instead
of PreRender, this event fires after the formview has performed
databinding operation. And I think it is better than the PreRender event.
Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)