Problem setting combobox display properties

2 posts, 0 answers
  1. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 19 Jul 2012 Link to this post

    As I have posted previously, I am using a radcombobox as a data selector in a radgrid. The combobox is filled with options for the user to select, but I only want the combobox visible if the user clicks on the existing item.

    All of the functionality works as expected, however, the combobox must be displayed the first time the page is rendered because setting the Visible property to false server-side prevents the html from being generated.

    I have tried setting an attribute in the style for display:none but it is not recognized and the combo still shows.
    How can I initially hide the combobox and still have the html generated?

    Also, while I might consider a client-side solution as a last resort, it is important to note that I have the potential for hundreds of comboboxes because as I stated previously, these are being used in a radgrid.

    Other points that might be important is that the data in the combobox is filled based on the value of a field in the current record. i.e. if column pID is 42, then all items in a specific table where pID is 42 are put into the combobox. This precludes the thought of creating the combobox dynamically client-side because I would need to make numerous postbacks everytime the combobox becomes visible. I am desparately trying to keep the number of server calls down. 
  2. Keith
    Keith avatar
    94 posts
    Member since:
    Jun 2012

    Posted 19 Jul 2012 Link to this post

    I decided to step back from this for a bit and the solution suddenly became apparent.

    In the ItemDataBound event for the radgrid, set the display attribute to none.
    RadComboBox cbx = e.Item.FindControl("ComboBoxNameGoesHere");
    cbx.Style.Add("Display", "none");

    I can't believe how simple it was.
Back to Top