My application consist of DataGridviewComboBoxColumn
inside DataGridView
. The ComboBoxColumn
s are getting filled from a database table (key, value pair). I am trying to set the default value for ComboBox
column using DefaultValuesNeeded
event but it is not working.
Following is the sample code:
e.Row.Cells["Job"] as DataGridViewComboBoxColumn).Value ="12"
But it shows 12 as value , instead of 12 it suppose to show actual text of 12 value.
For example:
DataGridViewComboBoxColumn dgvCbJob = new DataGridViewComboBoxColumn();
{
dgvCbJob.HeaderText = "Job";
hadd.Clear();
hadd.Add("@Search", string.Empty);
ds = ObjDAL.GetDataSetForPrc("prc_GetJobList", hadd);
if (ds.Tables[0].Rows.Count > 0)
{
dgvCbJob.DataSource = ds.Tables[0];
dgvCbJob.DisplayMember = "JobName";
dgvCbJob.ValueMember = "JobMasterId";
}
dgvCbJob.DisplayIndex = 0;
dgvCbJob.Width = 100;
dgvCbJob.Name = "Job";
}