DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Binding data to the RadioButtonList Control

This is a discussion on Binding data to the RadioButtonList Control within the .Net Development forums, part of the Programming & Scripting category; Hi guys trying to bind data to my RadioButtonList control, but i'm getting this error: Code: Description: An error occurred ...

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

  #1  
Old December 2nd, 2008, 10:45 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 292
Rep Power: 2
Shem is on a distinguished road
Default 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
Reply With Quote
  #2  
Old December 2nd, 2008, 11:48 AM
richyrich's Avatar
Administrator
 
Join Date: Mar 2008
Real name: Rich
Location: Somewhere only we know...
Posts: 1,347
Blog Entries: 6
Rep Power: 8
richyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to allrichyrich is a name known to all
Default

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

Comments on this post
Shem agrees: Thanked Post
Reply With Quote
The Following User Says Thank You to richyrich For This Useful Post:
Shem (December 3rd, 2008)
  #3  
Old December 3rd, 2008, 02:42 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 292
Rep Power: 2
Shem is on a distinguished road
Default

thanks RR

Shem

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

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Binding data... Shem .Net Development 6 July 7th, 2008 07:06 AM
The data source 'ObjectDataSource1' does not support sorting with IEnumerable data Shem .Net Development 5 June 25th, 2008 08:07 AM
WebCharts Control richyrich .Net Development 1 April 4th, 2008 11:14 AM


All times are GMT -4. The time now is 06:15 PM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2