We help IT Professionals succeed at work.
Get Started

How can i cast contents of a list into 2 fields withing a Grid

Olukayode Oluwole
on
52 Views
Last Modified: 2020-02-13
I have a Grid called dgvDetailsTables in my C# application

I need to populated 2 columns of the Grid   (Department and Division)

from a list . Currently A click puts the whole record into the Department column.

The code below loads the Combo within the Grid  and also gives me  a list within the Combo  to select from

 dgvcmbDepartment.DataSource = GlobalConfig.Connection.GetResponsibleMgr_All();
 dgvcmdDepartment.DisplayMember = "FullCodeName"


 public string FullCodeName => $"{divisioncode}  {deptcode }  { deptdesc} ";


See  the Grid with the Combo loaded  elements of "FullCodeName"

Combo Withing the Grid already having a list"

I now need to cast the content of "FullCodeName"  so that the first element   goes into column 6  (Division )

and the Second element goes into coulmn7 (Department)

I am trying to Cast the content of FullCodeName such that i can achieve this goal

but i know my cast statement has an error  ( See Code below )

Wrong  Cast  Statement
Can someone please help to look at the Cast statement and how i should modify it

so that on Click event  I get the 2 columns into the grid columns desired.

Thanks


Olukay
Comment
Watch Question
Chief Technology Ninja
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE