locked
how to add selection list dynamically with event RRS feed

  • Question

  • User581465447 posted

    hello friends i am trying to find solution for this problem if u know something then please tell i am creating web application that runs on black berry. here i need to create selection list which has three radio buttons in it. but these are created dynamically. and i want to add event "onselectedindexchanged" for this list. so how can i add this event when i am creating it dynamically. for static creation the code is of this kind --------------------------------------------------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestSelectionEvent.aspx.cs" Inherits="TestSelectionEvent" %><%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <META content="Microsoft Visual Studio .NET 7.1" name=GENERATOR> <META content=C# name=CODE_LANGUAGE> <script runat="server"> void mycall(Object sender, EventArgs e) { Response.Write("aaaa"); } </script> <?xml:namespace prefix = mobile /><mobile:Form id=Form1 runat="server"><mobile:Panel id=p1 Runat="server"><mobile:DeviceSpecific id=DeviceSpecific1 Runat="server"><CHOICE Filter="supportsJavaScript"><CONTENTTEMPLATE><?xml:namespace prefix = asp /><asp:RadioButtonList id=SelectionList1 runat="server" AutoPostBack="true" OnSelectedIndexChanged="SelectionList1_SelectedIndexChanged"><asp:ListItem>Yes</asp:ListItem> <asp:ListItem>No</asp:ListItem> </asp:RadioButtonList></CONTENTTEMPLATE></CHOICE><CHOICE Filter="supportsJavaScript"><CONTENTTEMPLATE><mobile:SelectionList id=SelectionList1 Runat="server" OnSelectedIndexChanged="SelectionList1_SelectedIndexChanged"><ITEM Value="Yes" Text="Yes"></ITEM><ITEM Value="No" Text="No"></ITEM></mobile:SelectionList></CONTENTTEMPLATE></CHOICE></mobile:DeviceSpecific></mobile:Panel></mobile:Form>------------------------------------------------------------------------------------------------------- here selection list is created in design view i.e. statically. but how can i do same when selection list is created dynamically if any one know please help me........ thank you.

    Wednesday, September 10, 2008 10:10 AM

Answers

  • User-2060689755 posted

    Hi swapnil1987,

    Please try following code, it works fine in my local. 

    SelectionList a;
        protected void Page_Load(object sender, EventArgs e)
        {
            //dynamically create radio buttons
            a = new SelectionList();
            a.ID = "selList";
            a.SelectType = ListSelectType.Radio;
            a.Items.Add(new MobileListItem("text1"));
            a.Items.Add(new MobileListItem("text2"));
            a.Items.Add(new MobileListItem("text3"));

            a.SelectedIndexChanged += new EventHandler(a_SelectedIndexChanged);
            this.Form1.Controls.Add(a);
          
        }

     

    Best regards,
    Guang-Ming Bian - MSFT

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 16, 2008 5:16 AM

All replies

  • User-2060689755 posted

    Hi swapnil1987,

    Please try following code, it works fine in my local. 

    SelectionList a;
        protected void Page_Load(object sender, EventArgs e)
        {
            //dynamically create radio buttons
            a = new SelectionList();
            a.ID = "selList";
            a.SelectType = ListSelectType.Radio;
            a.Items.Add(new MobileListItem("text1"));
            a.Items.Add(new MobileListItem("text2"));
            a.Items.Add(new MobileListItem("text3"));

            a.SelectedIndexChanged += new EventHandler(a_SelectedIndexChanged);
            this.Form1.Controls.Add(a);
          
        }

     

    Best regards,
    Guang-Ming Bian - MSFT

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 16, 2008 5:16 AM
  • User581465447 posted

    hi

    thanks for reply

    this code works fine only on IE but when i tried it on simulator of black berry it creates some problems.

    i have a static code as follows-------

    <!-- <mobile:Form id="Form1" runat="server" >

    <mobile:Panel ID="Panel1" Runat="server">

    <mobile:DeviceSpecific ID="DeviceSpecific1" Runat="server">

     

    <Choice Filter="supportsJavaScript">

     

    <ContentTemplate>

    <asp:RadioButtonList ID="SelectionList1" runat="server" OnSelectedIndexChanged="SelectionList1_SelectedIndexChanged" AutoPostBack="true" >

    <asp:ListItem>Yes</asp:ListItem>

    <asp:ListItem>No</asp:ListItem>

    </asp:RadioButtonList>

    </ContentTemplate>

    </Choice>

    <Choice Filter="supportsJavaScript">

    <ContentTemplate>

    <mobile:SelectionList ID="SelectionList1" Runat="server" SelectType="Radio" OnSelectedIndexChanged="SelectionList1_SelectedIndexChanged">

    <Item Text="Yes" Value="Yes" />

    <Item Text="No" Value="No" />

    </mobile:SelectionList>

    </ContentTemplate>

    </Choice>

     

    </mobile:DeviceSpecific>

     

    </mobile:Panel>

     

    </mobile:Form>

    -->

    this is what that code is but i am not able to do it dynamically.

    if u have some solution then pls reply..

     

    Tuesday, September 16, 2008 5:37 AM