Adding an item to a radiobuttonlist using Hashtable

Discussion in 'ASP' started by naimish, Aug 27, 2009.

  1. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth

    Introduction



    It helps us to add an item to a radio buttonlist from a Hashtable.

    The code



    Code:
    <script runat="server">
    sub Page_Load
    if Not Page.IsPostBack then
      dim mycountries=New Hashtable
      mycountries.Add("N","Norway")
      mycountries.Add("S","Sweden")
      mycountries.Add("F","France")
      mycountries.Add("I","Italy")
      rb.DataSource=mycountries
      rb.DataValueField="Key"
      rb.DataTextField="Value"
      rb.DataBind()
    end if
    end sub
    sub displayMessage(s as Object,e As EventArgs)
    lbl1.text="Your favorite country is: " & rb.SelectedItem.Text
    end sub
    </script>
    <html>
    <body>
    <form runat="server">
    <asp:RadioButtonList id="rb" runat="server"
    AutoPostBack="True" onSelectedIndexChanged="displayMessage" />
    <p><asp:label id="lbl1" runat="server" /></p>
    </form>
    </body>
    </html> 
    
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Moved it to forum.
     
  3. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,043
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    It was seeems an article :D
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice