• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

Datamember property 'tblComboBoxLkUp' cannot be found on the datasource

I have one combobox and one datagrid.  The combobox has the pk that connects to the datagrid.  
I would like to pick a combobox and show the details  of the selection in the datagrid.


I get error "Datamember property 'tblComboBoxLkUp' cannot be found on the datasource during the following statement:
CbMtd.DataSource = BindSrceMtd;
CbMtd.DisplayMember = "tblComboLkUp.Name_Lk";

I've checked spelling, case and I still can't figure out what is wrong with this!!  Please HELP!!!!

This is the rest of the code that I have:

 Ds = new DataSet();
 Cmd = new SqlCommand(SProcLkUp, CohortConn);
                Cmd.CommandType = CommandType.StoredProcedure;
 Da = new SqlDataAdapter(Cmd);
 Da.Fill(Ds, "tblComboLkUp");

//the above gets the information from the look up table that will be stored in the combobox


 Cmd 2= new SqlCommand(SProcDetails, CohortConn);
                Cmd2.CommandType = CommandType.StoredProcedure;
 Da2 = new SqlDataAdapter(Cmd)2;
 Da2.Fill(Ds2, "tblDetails");

//the above is the dataset that contains details.

 DataRela = new DataRelation(MtdDetails, Ds.Tables["tblComboLkUp"].Columns["ColNm1"], Ds.Tables["tblDetails"].Columns["ColNm2"], false);
Ds.Relations.Add(DataRela);

//data relation between combo and detail

 BindSrceMtd.DataSource = Ds;
 BindSrceMtd.DataMember = "tblComboLkUp";

BindSrceMtdDetail.DataSource = BindSrceMtd;
BindSrceMtdDetail.DataMember = "MtdDetails";//binded to relationship

           
DgvMtdDesc.DataSource = BindSrceMtdDetail;//datagrid bound to detail

CbMtd.DataSource = BindSrceMtd;
CbMtd.DisplayMember = "tblComboLkUp.Name_Lk";
CbMtd.ValueMember = "tblComboLkUp.ID_Lk";


0
yanci1179
Asked:
yanci1179
  • 3
  • 2
1 Solution
 
yanci1179Author Commented:
Anybody?  Pleasssseeee
0
 
sumixCommented:
CbMtd.DisplayMember = "Name_Lk";
0
 
yanci1179Author Commented:
such a small mistake has driven be crazy for the past 2 days!!!!  

thanks you SO MUCH for you help!!!!
0
 
yanci1179Author Commented:
just curious, why does it not take "tblComboLkUp.Name_Lk"?
0
 
sumixCommented:
Table name (tblComboLkUp) is specified in DataMember property of the binding source. In DisplayMember property you specify a field from the datasource from where the values displayed in combobox are taken. You don't need to mention the TableName again.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now