Can anyone help resolve this error

G

Guest

Hi

I have a datagrid that has a datatable as its datasource
currently the user is allowed to select a row from the datagrid and when they click the OK button, the values of the selected row are bound to textboxes. All the values bind properly except one value (Title

The error i recieve is

Cant bind to property or coloumn Title on datacource. Parameter name: datamembe

this message appears when i click the OK button. The message does not end the application but my binding code does not run
Here is my binding code

Tr
cn.Open(

da.Fill(Guest.dsGuest, "ClientDet"

txtTitle.DataBindings.Clear(
txtForename.DataBindings.Clear(
txtSurname.DataBindings.Clear(
txtaddress.DataBindings.Clear(
txtPostcode.DataBindings.Clear(
txtorganisation.DataBindings.Clear(
txtPhoneNo.DataBindings.Clear(

'display the records in the control
Guest.dsGuest.Tables("ClientDet").Select(
Me.txtTitle.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Title")
Me.txtForename.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Forename")
Me.txtSurname.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "SurName")
Me.txtaddress.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Address")
Me.txtPostcode.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "Postcode")
Me.txtorganisation.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "OrgName")
Me.txtPhoneNo.DataBindings.Add(New Binding("Text", Guest.dsGuest.Tables("ClientDet"), "PhoneNo")

'place the values from the controls into the global varible
TBTitle = txtTitl
TBPubFName = txtForenam
TBPubLName = txtSurnam
TBPubAddr = txtaddres
TBPubPCode = txtPostcod
TBPubPhoneNo = txtPhoneN
TBPubOrg = txtorganisatio
LabelExClientID = lblExClientI

Me.Close(

i declare the variables at the top of the form like so
Public Shared TBTitle As TextBo
Public Shared TBPubFName As TextBo
Public Shared TBPubLName As TextBo
Public Shared TBPubAddr As TextBo
Public Shared TBPubPCode As TextBo
Public Shared TBPubPhoneNo As TextBo
Public Shared TBPubOrg As TextBo

can anyone plz hel
 
M

Miha Markic [MVP C#]

Hi varun,

Are you sure that there is a column named Title in your datatable?
Btw, why are you calling: Guest.dsGuest.Tables("ClientDet").Select()?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

varun said:
Hi,

I have a datagrid that has a datatable as its datasource.
currently the user is allowed to select a row from the datagrid and when
they click the OK button, the values of the selected row are bound to
textboxes. All the values bind properly except one value (Title)
The error i recieve is:

Cant bind to property or coloumn Title on datacource. Parameter name: datamember

this message appears when i click the OK button. The message does not end
the application but my binding code does not run.
Here is my binding code:

Try
cn.Open()

da.Fill(Guest.dsGuest, "ClientDet")

txtTitle.DataBindings.Clear()
txtForename.DataBindings.Clear()
txtSurname.DataBindings.Clear()
txtaddress.DataBindings.Clear()
txtPostcode.DataBindings.Clear()
txtorganisation.DataBindings.Clear()
txtPhoneNo.DataBindings.Clear()

'display the records in the controls
Guest.dsGuest.Tables("ClientDet").Select()
Me.txtTitle.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Title"))
Me.txtForename.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Forename"))
Me.txtSurname.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "SurName"))
Me.txtaddress.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Address"))
Me.txtPostcode.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "Postcode"))
Me.txtorganisation.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "OrgName"))
Me.txtPhoneNo.DataBindings.Add(New Binding("Text",
Guest.dsGuest.Tables("ClientDet"), "PhoneNo"))
 
M

Miha Markic [MVP C#]

Hi,

Don't bind SelectedText as it is selected portion of text.
Rather, do bind Text property.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Varun said:
Hi Miha,

I have got rid of the error message now but i cannot get the combobox to
display the correct value that is in the datatable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top