回发时Dropdownlist不会保持价值 [英] Dropdownlist does not keep value when postback

查看:73
本文介绍了回发时Dropdownlist不会保持价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有服务器端下拉菜单,当我单击按钮时,它无法保持回发值
请帮助

I have server side droppdown it does not keeping value on post back when i am clicking on button
please help

推荐答案

您可能在Page_Load事件中将Dropdown绑定到数据库,而未选中Page.IsPostBack.试试这个

You are probably binding your Dropdown to your database in Page_Load event without checking Page.IsPostBack. Try this

void Page_Load (........) {
    if (!this.IsPostBack) {
        //Data Bind Dropdown here
    }
}





我从您的问题中了解到的是,您没有在回发后将databse值添加到下拉列表中.解决方案是您需要将数据绑定到回发中,而不是回发中.

如果对此有任何疑问,请对此发表评论.
问候,
shefeek
Hi,


What i understand from your question is that you did''nt get the databse value in to the dropdown after a postback.The sollution is you need to bind the data in postback and in not postback.

if any doubt in this please make comment on it.
regards,
shefeek




通过阅读此问题,您正面临这样的问题,我认为,您倾向于将项目放入下拉列表,如果那个时候发生任何回发,而您没有获得所选择的值,那么这就是您的问题所在.

用这种方式

1.添加headden提起

2.创建一个JavaScript数学方法并将dropdownlist值转换为headden字段值,然后通过使用headden filedvalue来在需要的地方(dropdownlist值)使用..

谢谢,
Naresh.G
Hi,

By reading this Question,you are facing the problem like this i think,you bend to items into the dropdownlist, if any post back is occurred that time you are not geting that value what you selected.if it is you problem means.

use this way

1.add headden filed

2.create one javascript mathod and take dropdownlist value into headden filed value and then you use where you need that (dropdownlist value) by using headden filedvalue..

Thanks,
Naresh.G


这篇关于回发时Dropdownlist不会保持价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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