为什么当我选择任何人下拉列表值时,为什么DropDownList默认采用第一个值 [英] Why DropDownList takes first value by default when I choose anyone drop down list value

查看:74
本文介绍了为什么当我选择任何人下拉列表值时,为什么DropDownList默认采用第一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,

当我从DropDownList中选择任何值时,为什么DropDownList默认采用第一个值(分配索引第0个值)?

注意:当我单击提交"按钮时,就会发生这种情况.

有什么错误吗?


莫汉.




为语法和可读性而编辑.

Dear sir,

Why does the DropDownList take first value by default(index 0th value assign), when I choose anyone values from the DropDownList?

Note: This happens when I click the submit button...

What is the error?


By mohan.




Edited for grammar & readability.

推荐答案

因为您没有检查Ispostback的正确性.

if(!IsPostBack)
{
//绑定下拉列表
}
Because you didn''t check Ispostback propery.

if(!IsPostBack)
{
//Bind your dropdown list
}


你好,
当您选择值,然后单击提交按钮.
然后它再次称为页面加载方法.
因此它将再次绑定您的下拉菜单.
并选择第一个默认值.

为此,您必须绑定,然后将其放入
ispostback方法

if(!ispostback)
{
//将您绑定到这里.
}
hello,
when u select value and then click on submit button.
then it again called the page load method.
therefore it will bind u r dropdown again.
and selected the first default value.

for that u have to bind u r drop down in
ispostback method

if(!ispostback)
{
//bind u r drop down here.
}


嗨 每当ASP页中发生任何事件时,都会调用第一页加载事件,然后再调用该事件,因此您的下拉列表会自动填充
在页面加载量上使用以下内容
if(!isPostBack)
{
填写您的下拉列表
}

然后运行您的代码并查看.
Hi Whenever any event occurs in ASP page first page load event is called followed by the event, so your dropdown list refills itself
use following on your pageload
if(!isPostBack)
{
fill ur dropdownlist
}

and then run your code and see.


这篇关于为什么当我选择任何人下拉列表值时,为什么DropDownList默认采用第一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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