Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

Posts   
 
    
like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 28-Aug-2007 15:24:05   

I keep running into this problem. I wonder if there are any particular things that cause this when binding dropdown lists within gridviews to LLBLGenProDatasources (v2). I've read loads of posts on other forums, but still don't understand what the problem is.

Any comments welcomed.

Self-servicing ora 9.2.0 asp.net (vb)

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 28-Aug-2007 18:31:24   

This most of the time is related on how we place the DataSources in the databinding scope and which fields are referenced.

Can you post some code to see how are you binding the DropDownLists?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 29-Aug-2007 10:39:45   

Sometimes this occurs when you use one of the above functions like Bind() on a control where there is no dataSource available to bind to. Like if you are having the dropdownList in the Grid's footer or in the EmptyTemplate of the Grid. The dataSource bound to the grid is not exposed to the controls in the footer ot in the EmptyTemplate.

like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 06-Aug-2008 12:10:40   

As a follow up... The same error seems to occur on InsertItemTemplate on listview.

Here is what I attempted:

<InsertItemTemplate>
      <tr>
              <td>
                   Rag Status
                  <asp:DropDownList ID="ddlRagStatusIdInsert" runat="server" DataSourceID="dsRagStatus"
                 SelectedValue='<%# Bind("RagStatusId") %>'
                    DataTextField="DescrShort" DataValueField="RagStatusId" AppendDataBoundItems="true">
                    <asp:ListItem Text="-Select-" Value="" Enabled="True"></asp:ListItem>
                  </asp:DropDownList>
</td></tr> etc...

I have got around this with:

 Private Sub lvIssue_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewInsertEventArgs) Handles lvIssue.ItemInserting

    e.Values("LastUpdate") = Now.ToString
    e.Values("LastUpdateBy") = HttpContext.Current.User.Identity.Name
    ' Grab selected value rather than binding with  SelectedValue='<%# Bind("RagStatusId") %>'

    e.Values("RagStatusId") = CType(CType(sender, ListView).InsertItem.FindControl("ddlRagStatusIdInsert"), DropDownList).SelectedValue

  End Sub

Hope this helps someone!