在js脚本调用button的click事件,程序会执行,但是dropdownlist在程序添加的Item不显示
<script type="text/javascript">function test()
{
var hf= Sys.UI.DomElement.getBounds("HiddenField1");
hf.value = "1|test1;2|test2;";
var ctl= Sys.UI.DomElement.getBounds("button1");
ctl.click();
}
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" Width="222px" CssClass="dropdownlist">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:HiddenField ID="HiddenField1" runat="server" />
<input
id="Button3" onclick="test()" type="button" value="button" />
</div>
</form>
CS文件
protected void Button1_Click(object sender, EventArgs e)
{
string temp = this.HiddenField1.Value;
string[] test;
test = temp.Split(';');
for (int i = 0; i < test.Length - 1; i++)
{
string[] key;
key = test[i].Split('|');
ListItem lm = new ListItem(key[1].ToString(), key[0].ToString(),true);
this.DropDownList1.Items.Add(lm);
}
}
--------------------编程问答-------------------- 涮新,重新绑定 --------------------编程问答-------------------- 刷新过,没有用 --------------------编程问答-------------------- 没有绑定撒 --------------------编程问答-------------------- 动态增加的ITEM,不是绑定数据源里面的数据 --------------------编程问答-------------------- 自己顶下 --------------------编程问答-------------------- 有人知道怎么处理么? --------------------编程问答-------------------- 接着顶下
补充:.NET技术 , C#