列の値を使用してドロップダウンに入力しようとしています。問題は、ドロップダウンで実際の値 (India(+61) のような国コード) を取得していないことです。代わりに、ドロップダウンで「System.Data.DataRowView」(複数回)を取得しています。
public void bind()
{
DataSet ds1 = new DataSet();
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]);
con.Open();
string strQuery = "select CountryCode from AUser";
SqlCommand cmd = new SqlCommand(strQuery, con);
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
da.Fill(ds1, "AUser");
ddlMobile.DataSource = ds1.Tables["AUser"];
ddlMobile.DataBind();
con.Close();
}
で bind メソッドを呼び出していpage_load
ます。のデータ型CountryCode
はvarchar(50)
& 値は次のようIndia(+91)
になりAustralia(+61)
ます...