datagridview problem

ElPollo123
ElPollo123 used Ask the Experts™
on
Hello All,
I am currently having a problem with a data grid view.
What is happening:

Columns in the data grid are "level", "width", "quantity", "section"
all of them are string formats with the exception of the section which is a dropdown box.

My problem is with the dropdown.
In the column properties for the dropdown I have "ElementID"  for the DataPropertyName
In my Code I set the ValueMember to "ElementID" as well.

When I run my application the dropdown has nothing selected but the dropdown works and I can select any item I want.
When I change the DataPropertyName to "SymbolId" (nothing else changed) and run it the dropdown has the item I want preselected, but the drop down nolonger works (meaning that I cannot select another if I wanted.  Not sure why this is.  The ideal option would be to have the dropdown preselected with the item I want and have the drop down in case the user wants to change.

Any help would be appreciated.
Thanks,

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Jini JoseSenior .Net Developer
Commented:
you can set the SelectedValue property of the dropdown to a databound item
Top Expert 2011
Commented:
Are you binding it when postback is false?

If no then change to when Page.IsPostback = false
Hi,

Ok, according to your comment, you have a Datasource for your dropdownbox that have a field called ElementID and in the Datasource of you grid you have a field with the same name correct?

What type of datasource are you using for your dropdownbox? you create one and assign it in the DataSource property of the column? or you are creating the Datasource on the fly and assign it by code?



Author

Commented:


Everyone,
Thanks,
the selectedvalue is what what I am looking for currently, but thanks,

postback is true at this point.

Yes i have a datasource for the drop down and a datasource for the datagridview.

lets call these combolist and dvlist

combolist had a field called elementid in it
dvlist has a field called symbolid

when these id's match the selected item of the combobox will be what the match is otherwise the selected item will be nothing, but the combo box will not drop down to display other options even though I know all the options are loading correctly.  the dropdown(combobox) does work, or drop down, with options when there is not a match in id's between the lists.
does this clear things up any?

The end result should be :  the combo box gets loaded with around 18 objects and one of them should be preselected to the user.  just wondering why the drop down is not working when i click to access the options...


It appears as I found the problem.
The culprit was some CSLA lists that my datagrid was binding to, I missed those when I ddi my initial conversion.  Changing those to a list(of T) worked just fine and my drop down box is working correctly now.  thanks chaps for the help.

Author

Commented:
Thanks for the help, believe it or not your responses did help me find the problem.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial