I have a combo box that I want to refresh the data of after the save button is clicked. I know that in web developer you can just say datasource.data bind but I do not see that in vb.net. Please can someone help me out.
Combo Box
Collapse
X
-
to clear the combobox type this following code
"comboboxname.i tems.clear();"
try this following for refresing the datas in the combobox,
"databind.refre sh();"Comment
-
There is no DataBind method for the combobox.
You should just be able to set the datasource to nothing and it should refresh. You may need to call the Update or the Refresh method for the combobox to force it to redraw on the page (as empty).Comment
-
Combo
OK, I promised to post here when I came right and I did not exactly come right but I saw how the first combo box was done. The person read through a dataset in a loop and did: combobox1.items .add("datacolum n"). I did want to change it to a datasource but still has to learn how they work but I think to set the datasource to nothing and give it again sounds good. in vb.net's comboboxes or any databound controls you cannot use databind. I am busy doing other combo boxes with datasources and will come tell of my successes. Thanks for your posts here and I hope I will be able to help any of you soon.Comment
-
-
ya you're correct, we cant do databind.refres h().Comment
-
Hi,
if you are adding items into the combobox using the database i recommend you the following code:
This will add items into your combobox. After that you can set the datasource to nothing and then select datasource again. Here is the code:Code:With comboBox1 .DataSource = Me.YourDataSetName.YourTableName .DisplayMember = Me.YourDataSetName.YourTableName.Columns(1).ColumnName .ValueMember = Me.YourDataSetName.YourTableName.Columns(0).ColumnName End With
i think this may help you.Code:comboBox1.DataSource = null comboBox1.Items.Clear() comboBox1.DataSource = Me.YourDataSetName.YourTableNameComment
Comment