Question How to prepopulate a listbox populated by dataset

santhosh_ms3

New member
Joined
Jun 3, 2012
Messages
1
Programming Experience
Beginner
I have a datagrid which has one custom column(List Box) which should be populated from the resultset of a SQL Stored Procedure. I used dataset to handle and assign the values to custom column(List Box). List box is populating from the dataset but i'm unable to show the default(actual) value in the listbox column instead its populating empty initially. what could be the problem. i set displaymember and valuemember properties to the customcolumn in the datagrid.

With Customgrid

If ds.tables(0).Rows.Count > 0 then
.Displaymember = "description"
.Valuemember = "description"
.DataSource = ds.Tables(0)

Is there anything to do with? whay the actual value for the row in datagrid is not showing from list box ?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,376
Location
Sydney, Australia
Programming Experience
10+
It seems rather odd to display a ListBox in a grid cell when a ComboBox, which is already supported by the DataGridView (which I assume that you're actually using) seems much more appropriate. Regardless, I would suggest that you actually start by testing using a standard combo box column and see if you can get it working there. If it works there and not in your custom column then you know that the issue is with your custom column specifically. If your custom column works properly then it will work when configured the same way as a regular combo box column.

So, what do your queries look like for the grid and the column? Have you set the DataPropertyName of the column? What have you set it to?
 
Top Bottom