System.Data.DataRowView in DropDownList

前端 未结 3 1318
不思量自难忘°
不思量自难忘° 2021-01-06 15:39

I am trying to populate a dropdown using values from a column. Now the problem is: I am not getting the actual values (the country codes like India(+61)) in the dropdown. In

3条回答
  •  悲哀的现实
    2021-01-06 16:01

    You should set the DataValueField and DataTextField Properties of the drop down.

    ddlMobile.DataSource = ds1.Tables["AUser"];
    ddlMobile.DataValueField = "CountryCode";
    ddlMobile.DataTextField = "CountryName";
    ddlMobile.DataBind();
    

    Here CountryCode and CountryName must be the column names corresponding to those values in your DataRow

提交回复
热议问题