大家好, 我有一个使用webforms的网络应用程序,我在Formview中有两个下拉列表。 我根据选择来填充一个下拉列表其他。只要没有发生回发,我就会看到列表正确填充但在回发后,我的下拉列表是空的。 我正在设置我在运行时填充的ddl的DataValueField属性该ddl的ViewStateMode设置为Enabled。 有谁知道原因是什么? 非常感谢。
Hi everyone, I have a web application using webforms and I have two dropdown lists inside a Formview. I am populating one dropdownlist based on the selection from the other. As long as there is no postback happening, I see the list getting populated correctly but after a postback, my dropdownlist is empty. I am setting the DataValueField property of the ddl that I populate at runtime and the ViewStateMode for that ddl is set to Enabled. Does anyone know what could be the reason? Thanks much.
推荐答案我强烈怀疑你在Page_Load事件中绑定了DropDownList。如果是这样,请按如下所示: I strongly suspect you binded your DropDownList in Page_Load event. If so,put it as follows: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //bind dropdown here } }
问候......
你指的是基于我填充其他ddl的ddl吗?我在if(!postback)中绑定了那个,但是另一个没有绑定。 我注意到在运行时填充的文本框的内容也会在回发后消失。 我将ddl移到了Formview之外,现在它在回发后保留了它的内容。 Formview中控件的具体内容在运行时填充,我怎么能让它们在回发后保留它们的值? 谢谢。 Are you referring to the ddl based on which I am populating the other ddl? I do bind that one in if(!postback) but the other one is not bound at all. I noticed that the contents of a text box that is filled at runtime also disappear after postback. I moved the ddl outside of the Formview and now it retains its contents after postback. What is specific about controls inside a Formview that are filled at runtime and how can I make them retain their values after postback? Thanks.
更多推荐
回发后,dropdownlist不显示任何值
发布评论