在aspx页面中回发后,下拉列表项清除。 [英] Drop down List items getting Cleared after Post back in aspx page.

查看:75
本文介绍了在aspx页面中回发后,下拉列表项清除。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在我的aspx页面中DropdownList Items在页面没有回发(第一次加载)时被绑定,但当我点击任何按钮时(保存,编辑)(所有下拉列表项都被清除。



可以任何一个PLZ帮助,我错过了下拉列表的任何设置。 />


我把

Hi,

In my aspx page the DropdownList Items are getting binded when the page is not post back(first time loading) but when I clicked any button like (save ,edit)( all the drop down List items are getting Cleared.

can any one plz help, am i missing any settings for the dropdown list.

I put

Page.EnableViewState = true;

放在If(!ispostback)上面



If(!IsPostback)

里面的代码是

above the If(!ispostback)

The code inside the If(!IsPostback)
is

Parameters param = new Parameters();
DataSet datasetddlInternetwght = new DataSet();
datasetddlInternetwght = param.GetDDLListInternetWght();
ddlIntrntweight.DataTextField = datasetddlInternetwght.Tables[0].Columns["paramname"].ToString();
ddlIntrntweight.DataValueField = datasetddlInternetwght.Tables[0].Columns["paramvalue"].ToString();
ddlIntrntweight.DataSource = datasetddlInternetwght;
ddlIntrntweight.DataBind();





其中Parameters是单独的.cs文件中的类。我第一次加载页面时收到数据绑定但是当点击任何按钮时,下拉列表中的项目(ddlIntrntweight)将被清除。我为下拉列表启用了View状态;



where Parameters is a class in a separate .cs file. I am getting the Data binded when the Page is loaded for the first time but when any button got clicked the items in the Drop down list(ddlIntrntweight) are getting cleared. i enabled the View state for the Drop down list;

推荐答案

您应该启用视图状态。转到DropdownList的属性并将enableviewstate设置为true。
You should enable view state.Go to properties of the DropdownList and set enableviewstate to true.


请确保以下步骤:



1)将下拉菜单绑定如

Please make sure the follow steps:

1) Bind the drop down like
if (!Page.IsPostBack)
       {
           ddlIntrntweight.DataSource = SqlDataSource1;
           ddlIntrntweight.DataBind();
       }





2)确保



2) Make sure

AutoPostBack="True"



3)确保


3) Make sure

EnableViewState="True";


必须有一些你的代码中的问题。如果你分享你的代码,我将不胜感激....



++ Subhendu
There must be some problem in your code. I would appreciate if you share your code....

++Subhendu


这篇关于在aspx页面中回发后,下拉列表项清除。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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