Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在下拉列表中,我的DataTextField是00000001,但它在selectedvalue中显示1_Asp.net_Vb.net_Data Binding - Fatal编程技术网

Asp.net 在下拉列表中,我的DataTextField是00000001,但它在selectedvalue中显示1

Asp.net 在下拉列表中,我的DataTextField是00000001,但它在selectedvalue中显示1,asp.net,vb.net,data-binding,Asp.net,Vb.net,Data Binding,在下拉列表中,我的DataTextField是00000001,但它在selectedvalue中显示1 Sub MerchantDropDown() Dim ds As New DataSet ds = Utilities.spMerchantName1() ddlMerchantDropDownList.DataSource = ds ddlMerchantDropDownList.DataTextField = "Merch

在下拉列表中,我的DataTextField是00000001,但它在selectedvalue中显示1

Sub MerchantDropDown()

        Dim ds As New DataSet
        ds = Utilities.spMerchantName1()
        ddlMerchantDropDownList.DataSource = ds
        ddlMerchantDropDownList.DataTextField = "MerchantName1"
        ddlMerchantDropDownList.DataValueField = "MerchantID"
        ddlMerchantDropDownList.DataBind()
        ddlMerchantDropDownList.Items.Insert(0, "All Merchant")

End Sub
IIf(ddlMerchantDropDownList.SelectedIndex = 0, "-999", ddlMerchantDropDownList.SelectedValue()))

这是下拉列表的默认行为。从下拉列表中选择值后,可以填充零

ddlMerchantDropDownList.SelectedValue.tostring.padleft(7,"0")

由于您设置了
DataValueField=“MerchantID”
,因此在本例中,
SelectedValue
的更多详细信息将是
MerchantID
的值

要获取
数据文本字段的值
,需要使用:

ddlMerchantDropDownList.SelectedItem.Text

这不是DropDownList的默认行为。这是数据类型的行为。如果你有一个整数,是的,00001是1。但是如果你有一个varchar,00001将是00001。此外,如果OP确实要填充,则它应该是
ddlmercommerditdropdownlist.SelectedValue.ToString().PadLeft(7,“0”)