PDA

View Full Version : [CLOSED] Geting combobox value and/or text from code behind



feanor91
Apr 26, 2012, 1:58 PM
Hello

On my grid, I have a row editor. In this editor I have 3 fields that have combobox editor.

I have to check in code behind that a year-month value have not been already added to my data.

On the select event I called a function that do the check.

I begin to get my editor like that:



ColYear = grd.ColumnModel.Columns(8)
ColMonth = grd.ColumnModel.Columns(9)

cboYear = ColYear.Editor(0)
cboMonth = ColMonth.Editor(0)

(I try to change
ColYear.Editor(0) by
ColYear.Editor.Primary but it is the same.)

after that, I do something like that :



INT_Year = cboYear.SelectedItem.Text


I get an error message :


Object referenced is nothing.


means my cboYear combo is nothing.

So how handle that?

Daniil
Apr 26, 2012, 4:23 PM
Hi,

A field of Editor is rendered outside the form. So, its value is not submitted automatically and you need to pass a selected value manually via ExtraParams.

feanor91
Apr 26, 2012, 4:38 PM
OK it is the solution I have found, in the Extraparams I pass a getValue() of the 3 combobox needed, meanwhile, there is no way to get the value or the text of a selected element of a combobx in code behind.

As we can set a value with combo.setValue() function, I though we can getthe value in the same way with something like getValue() bu function seems to be not implemented.

Daniil
Apr 26, 2012, 8:05 PM
As we can set a value with combo.setValue() function, I though we can getthe value in the same way with something like getValue() bu function seems to be not implemented.

Do you mean server side?

Well, the server side SetValue method just generates a respective JavaScript which will be sent in a response to be executed on client side.

If a ComboBox selected value is not submitted from client side, there is no way to get it on server side.

feanor91
Apr 27, 2012, 6:30 AM
Well, of course, from this point of view it must be hard.

so, OK, I get it, and will work with extraparams.

Thanks.