+ Reply to Thread
Results 1 to 3 of 3

Thread: Binding data to the RadioButtonList Control

  1. #1
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    Binding data to the RadioButtonList Control

    Hi guys

    trying to bind data to my RadioButtonList control,
    but i'm getting this error:

    Code:
    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
    
    Parser Error Message: Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.ListItem does not have a DataBinding event.
    
    Source Error:
    
    Line 50:                         <td class="generalPadding" colspan="2">
    Line 51:                             <asp:RadioButtonList ID="rblAddForms" runat="server">
    Line 52:                                 <asp:ListItem Text='<%#Eval("Name")%>' Value='<%#Eval("Idkey")%>' Enabled="true"></asp:ListItem>
    Line 53:                             </asp:RadioButtonList>
    Line 54:                             <asp:Repeater ID="rpAddForms" runat="server" OnItemDataBound="rpAddForms_OnItemDataBound">
    
    
    Source File: /keithdesign/CustomControls/specinstructions_interior.ascx    Line: 52
    
    aspx:
    Code:
    <asp:RadioButtonList ID="rblAddForms" runat="server">
                                    <asp:ListItem Text='<%#Eval("Name")%>' Value='<%#Eval("Idkey")%>'></asp:ListItem>
                                </asp:RadioButtonList>
    
    aspx.vb:
    Code:
    Public Sub Populate_rblAddForms()
            Dim FormsList As New FormsList
    
            myParams.OrderBy = "name ASC"
            FormsList = FormsManager.GetList(myParams)
    
            'bind data to rpAddForms repeater
            rblAddForms.DataSource = FormsList
            rblAddForms.DataBind()
        End Sub
    
    Above is how i bind data to almost everything? what's the correct way to
    bind to the RadioButtonList?

    Shem

  2. #2
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Try this:-
    Code:
    <asp:RadioButtonList ID="rblAddForms" runat="server" appenddatabounditems="true" datatextfield="Name" datavaluefield="Idkey" textalign="Left" />
    
    Hope that helps...

  3. #3
    Barn Enthusiast Shem is on a distinguished road Shem's Avatar
    Join Date
    Mar 2008
    Posts
    305
    Rep Power
    4

    thanks RR

    Shem
    Last edited by Shem; December 3rd, 2008 at 02:54 AM.

+ Reply to Thread

Similar Threads

  1. Binding data...
    By Shem in forum .NET Development
    Replies: 6
    Last Post: July 7th, 2008, 08:06 AM
  2. Replies: 5
    Last Post: June 25th, 2008, 09:07 AM
  3. WebCharts Control
    By richyrich in forum .NET Development
    Replies: 1
    Last Post: April 4th, 2008, 12:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO