dropdownlist --- value值相等的时候解决办法

 dropdownlist选择值的时候,靠,明明选择的是第三项, 点击后回发下,就变成了第二项了

 贴代码吧

这是前台代码,直接用的数据源绑定

  <asp:DropDownList ID="DDLpro" runat="server" DataSourceID="SqlDataSource2" DataTextField="PSNAME"
                            DataValueField="PID" Width="140px" onchange="SetPId(this);">
                        </asp:DropDownList>

  <input id="hSelectIndex" type="hidden" runat="server" />

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                            ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand='SELECT "PSNAME", "PID" FROM "BSC_PRODUCTSPEC" WHERE ("ACTIVEFLAG" = :ACTIVEFLAG)'>
                            <SelectParameters>
                                <asp:Parameter DefaultValue="2" Name="ACTIVEFLAG" Type="Decimal" />
                            </SelectParameters>
                        </asp:SqlDataSource>

 

利用JavaScript可以解决,

先要加上一个  <input id="hSelectIndex" type="hidden" runat="server" />隐藏控件

如下是js代码:

 

onchage="SetPid(this)"

 function SetPId(item){
        document.getElementById("<%=hSelectIndex.ClientID %>").value=item.selectedIndex;
        document.getElementById('<%=txtpid.ClientID %>').value=item.options[item.selectedIndex].value;
    }

 

然后再后台代码协上

if (!string.IsNullOrEmpty(this.hSelectIndex.Value))
        {
            this.DDLpro.SelectedIndex = Convert.ToInt32(this.hSelectIndex.Value);
        }

ddlpro是我的dropdownlist控件名:

 

 

 

然后把获取到的Z轴位置的去每帧设置morpher变形器 功能添加到这段代码中:rollout morpherControl "Morpher 通道控制器" width:300 height:400 ( -- 界面元素 dropdownlist ddlTargets "目标对象:" items:(for obj in objects collect obj.name) height:15 dropdownlist ddlMorphers "Morpher修改器:" items:#() height:10 spinner spnChannel "通道编号:" range:[1,100,1] type:#integer fieldWidth:40 spinner spnWeight "权重:" range:[0.0,100.0,0.0] type:#float fieldWidth:50 slider sldWeight "权重控制" range:[0,100,0] ticks:10 button btnApply "应用权重" listbox lbxChannels "可用通道" height:10 -- 定义函数 fn updateChannelList = ( if ddlTargets.selection > 0 and ddlMorphers.selection > 0 do ( local targetObj = getNodeByName ddlTargets.items[ddlTargets.selection] local morpherMod = targetObj.modifiers[ddlMorphers.items[ddlMorphers.selection]] if morpherMod != undefined and classOf morpherMod == Morpher do ( local channelNames = #() for i = 1 to 100 where (WM3_MC_HasData morpherMod i) do ( append channelNames (i as string + ": " + (WM3_MC_GetName morpherMod i)) ) lbxChannels.items = channelNames ) ) ) fn updateWeightDisplay chanIndex = ( if ddlTargets.selection > 0 and ddlMorphers.selection > 0 and chanIndex > 0 do ( local targetObj = getNodeByName ddlTargets.items[ddlTargets.selection] local morpherMod = targetObj.modifiers[ddlMorphers.items[ddlMorphers.selection]] if morpherMod != undefined and classOf morpherMod == Morpher do ( local weight = WM3_MC_GetValue morpherMod chanIndex spnWeight.value = weight sldWeight.value = weight ) ) ) fn applyWeight chanIndex weight = ( if ddlTargets.selection > 0 and ddlMorphers.selection > 0 and chanIndex > 0 do ( local targetObj = getNodeByName ddlTargets.items[ddlTargets.selection] local morpherMod = targetObj.modifiers[ddlMorphers.items[ddlMorphers.selection]] if morpherMod != undefined and classOf morpherMod == Morpher do ( if (WM3_MC_HasData morpherMod chanIndex) then ( WM3_MC_SetValue morpherMod chanIndex weight completeRedraw() ) else ( messageBox "选定的通道没有有效数据!" ) ) ) ) -- 新增:自动加载首个有效Morpher fn autoLoadFirstMorpher = ( for i = 1 to ddlTargets.items.count do ( ddlTargets.selection = i if ddlMorphers.items.count > 0 do ( ddlMorphers.selection = 1 updateChannelList() if lbxChannels.items.count > 0 do ( lbxChannels.selection = 1 spnChannel.value = 1 updateWeightDisplay 1 ) exit -- 找到有效对象后退出循环 ) ) ) -- 事件处理 on ddlTargets selected sel do ( local targetObj = getNodeByName ddlTargets.items[sel] if isValidNode targetObj do ( local morpherList = #() for mod in targetObj.modifiers where classOf mod == Morpher do ( append morpherList mod.name ) ddlMorphers.items = morpherList if morpherList.count > 0 then ddlMorphers.selection = 1 ) ) on ddlMorphers selected sel do updateChannelList() on lbxChannels selected sel do ( spnChannel.value = sel updateWeightDisplay sel ) on spnWeight changed val do ( sldWeight.value = val applyWeight spnChannel.value val ) on sldWeight changed val do ( spnWeight.value = val applyWeight spnChannel.value val ) on btnApply pressed do applyWeight spnChannel.value spnWeight.value -- 新增:对话框打开时自动加载 on morpherControl open do autoLoadFirstMorpher() ) createDialog morpherControl
最新发布
07-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值