Dynamically created checkbox and dropdown list how to get two field values

Thread is closed for posting
6 posts, 0 answers
  1. Tamim
    Tamim avatar
    64 posts
    Member since:
    May 2011

    Posted 08 Jun 2012 Link to this post


    In button click to Dynamically created checkbox and dropdown list how to get checkbox.checked=true and dropdown values to find

    This is my code
                 chk_Dynamic = new CheckBox();
                Panel1.Controls.Add(chk_Dynamic);
                dropdown = new RadComboBox();
                dropdown.ID = "dropdown";
                Panel1.Controls.Add(dropdown);
                dropdown.Height = Unit.Pixel(200);
                dropdown.Width = Unit.Pixel(110);
                dropdown.BackColor = System.Drawing.Color.LightGray;
                dropdown.Items.Insert(0, new RadComboBoxItem("--Select--", "-1"));
                dropdown.Items.Insert(1, new RadComboBoxItem("Today", "10000000000001"));
                dropdown.Items.Insert(2, new RadComboBoxItem("Yesterday", "10000000000002"));
                dropdown.Items.Insert(3, new RadComboBoxItem("This Week", "10000000000003"));
                dropdown.Items.Insert(4, new RadComboBoxItem("Last Week", "10000000000004"));
                dropdown.Items.Insert(5, new RadComboBoxItem("This Month", "10000000000005"));
                dropdown.Items.Insert(6, new RadComboBoxItem("Last Month", "10000000000006"));
                dropdown.Items.Insert(7, new RadComboBoxItem("This Quarter", "10000000000007"));
                dropdown.Items.Insert(8, new RadComboBoxItem("Last Quarter", "10000000000008"));
                dropdown.Items.Insert(9, new RadComboBoxItem("This Year", "10000000000009"));
                dropdown.Items.Insert(10, new RadComboBoxItem("Last Year", "10000000000010"));

    Advance
    Thanks
    Tamim
  2. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 08 Jun 2012 Link to this post

    Hi Tamim,

    You could access the requested values using the following approach:

       - first add these handlers to your dynamically generated controls:
    chk_Dynamic.AutoPostBack = true;
    dropdown.AutoPostBack = true;
     chk_Dynamic.CheckedChanged += new EventHandler(chk_Dynamic_CheckedChanged);
    dropdown.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(dropdown_SelectedIndexChanged);
       
        - using the created event handlers, get the currently made changes:
    void dropdown_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
       {
           string selected = e.Text;
       }
     
       void chk_Dynamic_CheckedChanged(object sender, EventArgs e)
       {
           bool isChecked = (sender as CheckBox).Checked;
       }

    That should do the trick.

    All the best,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tamim
    Tamim avatar
    64 posts
    Member since:
    May 2011

    Posted 08 Jun 2012 Link to this post

    Hi Eyup
    Thanks for ur reply...
    Now i have used radfilter control to click add expression to generate checkbox and dropdownlist.
    how can i get the dynamic checkbox and dropdown values.

    Thanks
    Ansari
  5. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 12 Jun 2012 Link to this post

    Hi Tamim,

    You could keep the selected and checked information as global variables and use them whenever needed. An alternative approach would be to use Session['object'] method to pass the entered values.

    Greetings,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Tamim
    Tamim avatar
    64 posts
    Member since:
    May 2011

    Posted 13 Jun 2012 Link to this post

    Thanks for ur Reply.
    Any example there?

    Thanks
    Tamim
  7. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 15 Jun 2012 Link to this post

    Hello Tamim,

    If you are using a regular RadFilter, the approach demonstrated in the following topic should work for you:
    http://www.telerik.com/community/forums/aspnet-ajax/mvc/how-to-get-radfilter-control-dropdown-field-type.aspx

    Regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017