I dynamically create a table with comboboxes and add it to PlaceHolder.
then I use a js script:
The problem is, that when I first time select a value in any of dinamically created combo - the value changes,
but if I then try to change the value to another - it seems, like it changes, but when combo closes it stays with
the value, that was selected first time. I mean, I cannot change selected value.
What is wrong?
private
void
CreateDynamicTable(
string
ProductCode)
{
//<skipped>
RadComboBox combo =
new
RadComboBox();
RadComboBoxItem l =
new
RadComboBoxItem();
combo.EmptyMessage =
"- PASIRINKITE -"
;
string
[] items = result.Expression.ToString().Split(
'|'
);
string
[] values = result.PriceCoefficient.ToString().Split(
'|'
);
int
itemsCount = result.Expression.ToString().Count();
foreach
(var item
in
items.Zip(values, (ix, v) =>
new
{ ix, v }))
{
l =
new
RadComboBoxItem(item.ix, item.v);
combo.Items.Add(l);
}
tc.Attributes.Add(
"width"
,
"145px"
);
combo.Attributes.Add(
"Style"
,
"font-family: verdana; width: 140px; font-size : 7pt"
);
combo.ID =
"cboAttributeName_"
+ i.ToString();
combo.ClientIDMode = ClientIDMode.Static;
combo.OnClientSelectedIndexChanged =
"SelectedIndexChanged"
;
combo.Attributes.Add(
"AtributeName"
, result.AttributeName);
tc.Controls.Add(combo);
<skipped>
}
var
attributes_array =
new
Array();
function
SelectedIndexChanged(sender, eventArgs) {
var
item = eventArgs.get_item();
var
dblCofficient = parseFloat(item.get_value());
var
dblActualPrice = document.getElementById(
'lblActualPrice'
).innerHTML;
if
(dblCofficient > 0) {
var
strlblYourPrice = document.getElementById(
'lblYourPrice'
).innerHTML;
var
strlblUsualPrice = document.getElementById(
'lblUsualPrice'
).innerHTML;
document.getElementById(
'lblYourPrice'
).innerHTML = roundNumber(dblActualPrice * (dblCofficient / 100), 2).toFixed(2).toString().replace(
"."
,
","
) +
' Lt.'
;
document.getElementById(
'lblActualPriceDb'
).innerHTML = roundNumber(dblActualPrice * (dblCofficient / 100), 2).toFixed(2);
document.getElementById(
'lblUsualPrice'
).innerHTML = roundNumber(dblActualPrice * 1.25 * (dblCofficient / 100), 2).toFixed(2).toString().replace(
"."
,
","
) +
' Lt.'
;
}
var
AtributeName = sender.get_attributes().getAttribute(
"AtributeName"
);
var
AtributeValue = item.get_text();
var
field = document.getElementById(
'txtAttributes'
).value;
attributes_array[AtributeName] = AtributeValue;
var
str;
for
(
var
key
in
attributes_array) {
if
(attributes_array.hasOwnProperty(key)) {
str +=
" "
+ key +
": "
+ attributes_array[key] +
";"
//существующий формат, или:
}
}
str = str.substr(10);
document.getElementById(
'txtAttributes'
).value = str;
}