开发者

ComboBox values Retrival and assign to Stored Procedure

I have ComboBox and I fill it with a Dataset:

comboBox1.DataSource = ds1.Tables[0];
comboBox1.DisplayMember = "post_co开发者_如何转开发de";

where ds1 is dataset with one column post_code

It is sucessfuly showing data in ComboBox but when I am trying to save that ComboBox value in Table with:

cmd = new SqlCommand("Mt_Vacancy_mainPreference_insert",con);
cmd.Parameters.Add("@post_name", SqlDbType.NChar).Value = comboBox1.SelectedItem.ToString().Trim();

it shows Error as Data.DataRowView. I also tried using SelectedValue.


Assign the ValueMember of comboBox1.

comboBox1.ValueMember = "YourValueField";

then use SelectedValue of comboBox1

string x = comboBox1.SelectedValue;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜