dynamically adding values to RadioButton

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • premprakashbhati
    New Member
    • Dec 2008
    • 25

    dynamically adding values to RadioButton

    happy new year all of u...
    sir,
    iam using dataservice function of type int[] named getunbookedslot s(DateTime dt) and the same is used for adding the returned datetime value to RadioButtonList of other .aspx page dynamically...
    here is the Code in Page_Load() of page aspx.cs....
    Code:
    DataService myservices = new DataService();
        protected void Page_Load(object sender, EventArgs e)
        {
            string s = "";
            DateTime dt =  DateTime.Now ;
            s = Request.QueryString["monthday"].ToString();
            s = s + " " + Request.QueryString["monthdate"].ToString();
    
            RadioButtonList lt = new RadioButtonList();
            
            //lt.Items.Add("9.00 to 9.30 AM");
            //lt.Items.Add("10.00 to 10.30 AM");
    
            int[] value = myservices.getunbookedslots(dt);
            lt.Items.Add(value.ToString()); //i want to know the code to be replaced here//
           
    
            cont.Controls.Add(lt);
            Response.Write(s);
            
        }
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    It seems as though the radio button is the wrong type of control for this data, have you tried a combobox or a dropdown?

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by premprakashbhat i
      happy new year all of u...
      sir,
      iam using dataservice function of type int[] named getunbookedslot s(DateTime dt) and the same is used for adding the returned datetime value to RadioButtonList of other .aspx page dynamically...
      here is the Code in Page_Load() of page aspx.cs
      .......
      You haven't stated the problem that you're having.
      In order for us to help you you need to tell us what the problem is and what you've tried so far to solve the problem.

      It doesn't look like you correctly creating/declaring/using your controls dynamically.

      Check out this article on how to use dynamic controls in ASP.NET to understand why you're having problems.

      -Frinny

      Comment

      Working...