jQuery和ASP.NET dropdownlist自动回发事件 [英] jQuery and ASP.NET dropdownlist autopostback event

查看:66
本文介绍了jQuery和ASP.NET dropdownlist自动回发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由jQuery填充的下拉列表,并且下拉列表具有自动回发事件.
我想通过jQuery调用一个dropdownlist选择的索引更改事件,并在ASP.NET Gridview中加载数据,但是当我从dropdownlist中选择一个项目时数据消失了.

给我一个合适的解决方案.

I have a dropdownlist which is populated by jQuery and dropdownlist has a autopostback event.
I want to call a dropdownlist selected index changed event by jQuery and load data in ASP.NET Gridview, but data is vanished when I select a item from dropdownlist.

Give me a suitable solution.

推荐答案

您正在向客户端的下拉列表中添加项目,但是当回发发生时,服务器端会从因此,视图状态将使新项目消失".

您需要a)将项目添加到服务器上的下拉列表中,或b)在客户端上创建新项目时记录它们的详细信息(可能以隐藏的形式变量),并在发生回发时使用这些详细信息在服务器端添加新项目.
You''re adding items into the dropdown on the client, but when the postback happens, the server-side rebuilds the dropdown from the viewstate therefore the new items "vanish".

You need to either a) add the items into the dropdown on the server or b) record details of the new items when they''re created on the client (in a hidden form variable probably) and when the postback occurs, use those details to add the new items on the server-side.


这篇关于jQuery和ASP.NET dropdownlist自动回发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆