Radiobuttonlist Image Setting

Last post 08-17-2009 5:55 AM by chope_07. 8 replies.

Sort Posts:

  • Radiobuttonlist Image Setting

    10-02-2003, 11:56 AM
    • Member
      15 point Member
    • morgation
    • Member since 08-13-2003, 1:38 PM
    • Posts 3
    I am attempting to create a radiobuttonlist as a result of value retrieved from the db. In the db i have a name of picture file in which i will return. I want the radiobuttons to interpret this value and populate an image. I am currently doing this with an image displaying in a datagrid but not for a radiobutton.

    Here is what i have, but it will not retrieve the image?

    <asp:RadioButtonList id="RadioButtonList1" runat="server">
    <asp:ListItem >
    <img src='/pic_directory_here/ <%# fixpicture(Container.DataItem("pic_name_here")) %>
    </asp:ListItem>
    </asp:RadioButtonList>
  • Re: Radiobuttonlist Image Setting

    10-02-2003, 2:39 PM
    • Member
      740 point Member
    • macha27
    • Member since 08-05-2002, 10:20 AM
    • Posts 148

    1) Your image tag is not complete. It should be:

    <img src='/pic_directory_here/<%# fixpicture(Container.DataItem("pic_name_here"))%>'>

    (quote and closing tag at the end)

    2) Did you look at (can you show us part of) the html generated when the page is rendered?


    3) Can you show us your databind() code for the radiobuttonlist?

    4) Try this

    <img src='/pic_directory_here/<%# Container.DataItem("pic_name_here")%>'>

    to see if there is a problem with your fixpicture method.


    -ron
  • Re: Radiobuttonlist Image Setting

    10-06-2003, 2:09 PM
    • Member
      15 point Member
    • morgation
    • Member since 08-13-2003, 1:38 PM
    • Posts 3
    Ron,

    I tried this and it still will not find my images. Here is what the HTML translated to:

    <ItemTemplate>
    <asp:RadioButtonList id="RadioButtonList1" runat="server">
    <asp:ListItem >&lt;img src='/peifootball/gifs/&lt;%# Container.DataItem(&quot;team_pic&quot;) %&gt;' &gt; </asp:ListItem>
    </asp:RadioButtonList>
    </ItemTemplate>
    </asp:DataList>

    How does the databinding work with the radiobutton list? I am only databinding the datalist.
  • Re: Radiobuttonlist Image Setting

    10-06-2003, 9:03 PM
    • Member
      740 point Member
    • macha27
    • Member since 08-05-2002, 10:20 AM
    • Posts 148


    I was asking about the HTML that is rendered in the client. Look at that and see if there is an <img src

    -ron
  • Re: Radiobuttonlist Image Setting

    10-07-2003, 9:11 AM
    • Member
      15 point Member
    • morgation
    • Member since 08-13-2003, 1:38 PM
    • Posts 3
    <img src='/peifootball/gifs/<%# Container.DataItem("team_pic") %>' >

    I am not sure if this is what you want but this is what is generated. I am just not sure if radiobuttons can be generated from a file name retrieved from the database. It will work if i hard code the name of the file into the img src but not when i bring in the db value.

  • Re: Radiobuttonlist Image Setting

    10-07-2003, 10:23 AM
    • Member
      740 point Member
    • macha27
    • Member since 08-05-2002, 10:20 AM
    • Posts 148
    Try this:


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    If Not IsPostBack Then
    GenImage()
    End If

    End Sub

    Sub GenImage()
    Dim a As ArrayList = New ArrayList
    a.Add("bl.gif")
    a.Add("bc.gif")
    a.Add("cc.gif")
    For Each s As String In a
    RadioButtonList1.Items.Add(New ListItem("<img src=""" + s + """/>", s))
    Next
    End Sub

    and this on the html page

    <asp:RadioButtonList id="RadioButtonList1" runat="server"></asp:RadioButtonList>


    -ron
  • Re: Radiobuttonlist Image Setting

    07-22-2008, 10:28 AM
    • Member
      6 point Member
    • greatbear
    • Member since 07-07-2008, 9:33 PM
    • Posts 27

     The ListItem tag should contain a "value" attribute for the image to appear. ;)

    <asp:signature text="GreatBear" runat="server" />
  • Re: Radiobuttonlist Image Setting

    10-23-2008, 3:34 PM

    Hi, I am facing the same problem.

    Following is my aspx code :

    <tr><td >asp:RadioButtonList ID="rlCards" runat="server"></asp:RadioButtonList></td></tr>

    aspx.cs code is :

    string img1 = "<img src='images/ <%# fixpicture(Container.DataItem(\"card"+Card.CardId+".jpg\")) %>'>";

    ListItem listItem = new ListItem(img1, Card.CardId.ToString());

    rlCards.Items.Add(listItem);

     

    I want my radiolist rlCards to be associated with the images in folder images and image name as (card+cardId).jpg

    Is there any way, I can get that correctly.

    Thanks in advance.

    Rashmi

  • Re: Radiobuttonlist Image Setting

    08-17-2009, 5:55 AM
    • Member
      12 point Member
    • chope_07
    • Member since 04-22-2009, 1:25 AM
    • Parañaque, Philippines
    • Posts 6

    I know ot was too late then, but somebody might be looking for the same solution.


    Maybe you could try this solution.

    <asp:RadioButtonList id="RadioButtonList1" runat="server"> 
    <asp:ListItem > 
    <%# "<img src=\"/pic_directory_here/" +  fixpicture(Container.DataItem("pic_name_here").ToString()) + "\"" %> 
    </asp:ListItem> 
    </asp:RadioButtonList>

    Developing Skills. Sharing Skills.
    http://www.stringlist.com
Page 1 of 1 (9 items)