Hi here i want to bind some values to check box dynamically.
dataset ds = //getting emp values form database;
cbemp.ValueMember = "empid";
cbemp.DisplayMember = "empname";
cbemp.DataSource = ds.Tables["emp"];
it is working fine. But i want to add
“Select emplyoee” as a default value of check box .
But my check box directly adding values like
a1
a2
a3
like this.
I tried like this
cbemp.Items.Insert(0, "Select emplyoee");
but it is not working
how can i add it?
When you use databinding, you cannot “manually” add or remove items. The only way to achieve what you want using databinding is to insert a row first in the
DataTablewith the desired value, or to populate the combobox by code (add the “Select employee” item and then iterate of the theDataTablerows to add the records).Perhaps something like this could work:
I don’t use databinding much, so there may be drawbacks with this that I am unaware of (but I am confident that the community will point that out in that case).