Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在设置下拉值之前调用javascript函数_Javascript_C#_Asp.net - Fatal编程技术网

在设置下拉值之前调用javascript函数

在设置下拉值之前调用javascript函数,javascript,c#,asp.net,Javascript,C#,Asp.net,我在gridview模板字段中有一个下拉列表,并将rowIndex传递给javascript函数。看起来javascript函数是在下拉列表中的值完全更改为所选值之前启动的。因此,我总是得到返回的第一个索引,即使我从下拉列表中选择了其他索引 <asp:TemplateField HeaderText="Establishment"> <ItemTemplate> &l

我在gridview模板字段中有一个下拉列表,并将rowIndex传递给javascript函数。看起来javascript函数是在下拉列表中的值完全更改为所选值之前启动的。因此,我总是得到返回的第一个索引,即使我从下拉列表中选择了其他索引

 <asp:TemplateField HeaderText="Establishment">
                        <ItemTemplate>
                            <asp:DropDownList ID="drpUserEstablishment" CssClass="dropdown" ClientIDMode="Static"
                                runat="server" AutoPostBack="false"
                                onchange='<%#"setUserEstablishment(" + Container.DataItemIndex +")"%>'>
                            </asp:DropDownList>

                       </ItemTemplate>

  </asp:TemplateField>
传递“this”,然后在函数中使用它似乎可以解决这个问题

onchange='<%#"test(" + "this"+","+Container.DataItemIndex +")"%>'

 function test(ddl,rowindex) {

                                      var index = ddl.selectedIndex;

                                      alert("rowindex=" + rowindex);

                                      alert('Selected Value = ' + ddl.value + '\r\nSelected Index = ' + index);
}
onchange=''
功能测试(ddl、行索引){
var指数=ddl.selectedIndex;
警报(“rowindex=“+rowindex”);
警报('Selected Value='+ddl.Value+'\r\n Selected Index='+Index);
}
onchange='<%#"test(" + "this"+","+Container.DataItemIndex +")"%>'

 function test(ddl,rowindex) {

                                      var index = ddl.selectedIndex;

                                      alert("rowindex=" + rowindex);

                                      alert('Selected Value = ' + ddl.value + '\r\nSelected Index = ' + index);
}