In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to solve the problem that DropDownList always chooses the first item, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.
In the process of web page development, I used a DropDownList server control in the page, and found a very strange problem. No matter which item is selected in the page, the value obtained in the background is always the value of the first item. After looking at it for a long time, I did not find out where the problem lies. DropDownList control has been used countless times in the development, compared with other code is the same!
After a few minutes, I really can't see where the problem lies and have to look for answers online. Sure enough, many people on the Internet encounter the same problem-DropDownList always chooses the first one. The online solution is to use if (! IsPostBack) in the Page_Load event when DropDownList is bound, but I am bound in this way, and I still haven't found a solution on the Internet.
Later, I quietly pondered, is it because when binding DropDownList, only assign values to Text, but not assign values to Value? Then I tried to assign the Value of each item, and sure enough, there was no such phenomenon!
Now summarize two reasons why the DropDownList control always selects the first item.
In case one, look at the following code:
Client code:
Server code:
Protected void Page_Load (object sender, EventArgs e) {BindDropDownList ();} private void BindDropDownList () {ddl1.Items.Clear (); / / clear all items for (int I = 1; I) before each binding
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.