This is a migrated thread and some comments may be shown as answers.

Problem setting combobox display properties

1 Answer 123 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 2
Keith asked on 19 Jul 2012, 03:33 PM
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. 

1 Answer, 1 is accepted

Sort by
0
Keith
Top achievements
Rank 2
answered on 19 Jul 2012, 05:09 PM
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.
Tags
ComboBox
Asked by
Keith
Top achievements
Rank 2
Answers by
Keith
Top achievements
Rank 2
Share this question
or