Why does DropDownList always get the value of the first item???

Source: Internet
Author: User

Side dishes: DropDownList control binding data, in the acquisition of data always get to the first item, is depressed, how to, so on all kinds of thinking, have not found the cause of the problem. Take a look at the code in the foreground below:
         <asp:dropdownlistID= "Dropdownlistkind"runat= "Server">        </asp:dropdownlist>        <BR/>        <BR/>        <Asp:buttonID= "Button1"runat= "Server"Text= "button"onclick= "Button1_Click" />


Background code:

To seriously look at the above code yo, you can find the problem of the location.

Ha ha!

The answers are now revealed:

All are Dropdownlistkind.datavaluefield = "Kind"; The Curse of the cause

So the value of DropDownList is the same after the binding, so it is not wrong to blame it.

therefore Dropdownlistkind.datavaluefield = "Kind";

Change to Dropdownlistkind.datavaluefield = "Name";

is not suddenly enlightened. Summary: The vaule value of DropDownList should be kept unique. The control is not deeply understood. Do not know the fur, but do not know the structure of the root of it. Study hard, come on! Little rookie.


Why does DropDownList always get the value of the first item???

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.