请有人帮我解释为什么我在我的文本框中得到“System.Data.DataRowView”而不是“44”,这是我期望看到的?如果从下拉列表中再次选择它,那么它会为我填充该字段。我试过阅读很多论坛。
再次谢谢你
private void E164Convertor_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("CountryName");
DataColumn dc2 = new DataColumn("CountryCode");
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Rows.Add("United Kingdom" ,"44");
dt.Rows.Add("United States" , "1");
cbxctry.DataSource = dt;
cbxctry.DisplayMember = "CountryName";
cbxctry.ValueMember = "CountryCode";
}
private void cbxctry_SelectedIndexChanged(object sender, EventArgs e)
{
txtctrycode.Text = cbxctry.SelectedValue.ToString();
}