hi,
if i select one item in combobox,click ok button then that items GUID is saved in table,i want save the GUID of which item i selected in the Combobox.i dont want save the selected item.plz give the code,plz help me,plz
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Roei BarRank #1,271 · 1.4K reputationPosted Sep 3, 2009, 10:45 PM EDT
select id,value from tbl
the ID is the guid and the value is the display
than on the combo bind it to the sql return datatable
this.cbPositions.DataSource =dt;
this.cbPositions.DisplayMember = "Name";
this.cbPositions.ValueMember="ID";
and on selected take cbPositions.selectedValue
roy himanshu98 reputationPosted Sep 4, 2009, 9:29 PM EDT
its working but column name is saved but valuenot saved.plz help me.my codeing is paste below
private void Itemmaster_Load(object sender, EventArgs e)
{
cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["con"]);
da1 = new SqlDataAdapter("select *from ITEMMASTER", cn);
da2 = new SqlDataAdapter("select *from ITEMCATAGARY", cn);
ds = new DataSet();
da1.Fill(ds, "ITEMMASTER");
da2.Fill(ds, "ITEMCATAGARY");
cmd = new SqlCommand();
comboBox1.DataSource = ds.Tables["ITEMCATAGARY"];
comboBox1.DisplayMember = "Itemname";
comboBox1.ValueMember = "guid";
comboBox1.EndUpdate();
}
private void Add_btn_Click(object sender, EventArgs e)
{
try
{
DataRow dr = ds.Tables["ITEMMASTER"].NewRow();
dr[1] = textBox1.Text;
dr[2] = textBox2.Text;
dr[3] = textBox3.Text;
dr[4] = comboBox1.ValueMember.ToString();
dr[5] = textBox5.Text;
dr[6] = textBox6.Text;
dr[7] = dateTimePicker1.Text;
dr[8] = textBox8.Text;
dr[9] = textBox9.Text;
dr[10] = textBox10.Text;
dr[11] = textBox11.Text;
dr[12] = textBox12.Text;
dr[13] = textBox13.Text;
dr[14] = textBox14.Text;
ds.Tables["ITEMMASTER"].Rows.Add(dr);
cb = new SqlCommandBuilder(da1);
da1.Update(ds, "ITEMMASTER");
MessageBox.Show("Data Saved Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
foreach (Control item in Controls)
{
if (item is TextBox)
{
item.Text = "";
}
}
}
PLZ HELP ME