?
Solved

How do I Attribute.Add from repeater to radio button?

Posted on 2009-12-24
2
Medium Priority
?
495 Views
Last Modified: 2013-11-26
I want to assign data from the repeater control to my radio button so when I click the radio button and can work with the data in JavaScript.
<ItemTemplate>
        <tr>        
            <td><asp:RadioButton GroupName="radGroup" ID="radMinus1" AutoPostBack="false" runat="server" /></td>
            <td><asp:RadioButton GroupName="radGroup" id="radAdd1" AutoPostBack="false" runat="server" /></td>
            <td>&nbsp;&nbsp;<%#DataBinder.Eval(Container.DataItem, "PartWeight")%></td>
        </tr>         
    </ItemTemplate>


CODE BEHIND
IN THE SECOND CTYPE I AM PASSING THE WORD 'TEST'. THAT IS WHERE I NEED TO PASS THE VALUE OF PartWeight WHICH IS WHAT I AM TRYING TO FIGURE OUT IN THE FIRST CTYPE BUT IT ISN'T WORKING.

    Protected Sub rptParts_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptParts.ItemDataBound
        Select Case e.Item.ItemType
            Case ListItemType.AlternatingItem, ListItemType.Item, ListItemType.EditItem
                CType(e.Item.FindControl("radMinus1"), RadioButton).Attributes.Add("onclick", "javascript: jsRadioChecked('" + CType(e.Item.FindControl("radMinus1"), RadioButton).ClientID + "', '" + e.Item.DataItem("PartWeight").ToString() + "');")
                CType(e.Item.FindControl("radAdd1"), RadioButton).Attributes.Add("onclick", "javascript: jsRadioChecked('" + CType(e.Item.FindControl("radAdd1"), RadioButton).ClientID + "', 'test');")

        End Select

    End Sub

Open in new window

0
Comment
Question by:Chuck98RT10
2 Comments
 
LVL 9

Expert Comment

by:Stephan_Schrandt
ID: 26122012
What exactly is the error?
0
 

Accepted Solution

by:
Chuck98RT10 earned 0 total points
ID: 26122234
Nevermind I got it working by adding a label inside the td
<td>&nbsp;&nbsp;<asp:Label ID="lblWeight" runat="server"><%#DataBinder.Eval(Container.DataItem, "PartWeight")%></asp:Label></td>

Open in new window

0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question