S
sck10
Hello,
I am trying to bind an arraylist to a FormView DropDownList control in the
PreRender state. The error that I get is the following:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control. Any help with this would be
appreciated.
--
Thanks in advance,
sck10
ASP.NET file
--------------
<td style="width:70%; text-align:left;">
<asp
ropDownList id="ddlRevenueYearInsert" Runat="Server"
SelectedValue='<%# Bind("RevenueYear") %>'/></td>
</tr>
CodeBehind File
-----------------
Protected Sub fvCustRev_PreRender(ByVal sender As Object, ByVal e As
EventArgs) Handles fvCustRev.PreRender
If Me.fvCustRev.CurrentMode = FormViewMode.Edit Then
Me.hdnPresentMode.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(ctrFor)
Next
arrFor.TrimToSize()
'Assign list to FormView datacontrol
If Me.hdnPresentMode.Value = "fvCustRev.Edit" Then
CType(Me.fvCustRev.FindControl("ddlRevenueYearEdit"),
DropDownList).DataSource = arrFor
CType(Me.fvCustRev.FindControl("ddlRevenueYearEdit"),
DropDownList).DataBind()
End If
End Sub
I am trying to bind an arraylist to a FormView DropDownList control in the
PreRender state. The error that I get is the following:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in
the context of a databound control. Any help with this would be
appreciated.
--
Thanks in advance,
sck10
ASP.NET file
--------------
<td style="width:70%; text-align:left;">
<asp
SelectedValue='<%# Bind("RevenueYear") %>'/></td>
</tr>
CodeBehind File
-----------------
Protected Sub fvCustRev_PreRender(ByVal sender As Object, ByVal e As
EventArgs) Handles fvCustRev.PreRender
If Me.fvCustRev.CurrentMode = FormViewMode.Edit Then
Me.hdnPresentMode.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(ctrFor)
Next
arrFor.TrimToSize()
'Assign list to FormView datacontrol
If Me.hdnPresentMode.Value = "fvCustRev.Edit" Then
CType(Me.fvCustRev.FindControl("ddlRevenueYearEdit"),
DropDownList).DataSource = arrFor
CType(Me.fvCustRev.FindControl("ddlRevenueYearEdit"),
DropDownList).DataBind()
End If
End Sub