Combox 与 DropDownList 的使用区别

combox 的使用

                    cb_WareHouseName.DataSource = dt;

             cb_WareHouseName.DisplayMember = "StockName";

             cb_WareHouseName.ValueMember = "ID";

 

dropdownlist 的使用

                    ddlWareHouseName.DataSource = pdas.GetStockInfo();

                        ddlWareHouseName.DataTextField = "StockName";

                        ddlWareHouseName.DataValueField = "ID";

                        ddlWareHouseName.DataBind();

                        ListItem li = newListItem();

                        li.Text = "==请选择==";

                        ddlWareHouseName.Items.Insert(0, li);

 

string s=DropDownList1.SelectedItem.Text;//这是获取选中的文本值((实际显示的内容))
string s=DropDownList1.SelectedValue//
获取DropDownList中你设定的Value(隐藏对应的值)

int i = DropDownList1.SelectedItem.ItemIndex; //获取当前先中的Index

 

combox1.text 这是获取选中的文本值((实际显示的内容))

combox1.SelectedIndex=-1 取消当前选中项

 

 

 

你可能感兴趣的:(combox,dropdownlist,selectedItem,SelectedValue)