Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataReleation Error!
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00751078
Message ID:
00755992
Views:
10
I think the runtime error you are receiving "Value cannot be null." is in the actual stuffing of the data value into the textbox, which expects a string. You can confirm this by adding code to the bindings Format event that stuffs an empty string when it encounters a null.


>In this case I get this compile error " 'Member' is not member of 'System.Data.DataSet' "
>
>And if wrote this:
>
>Me.txtWeight.DataBindings.Add("Text", myDS.Tables("Member.MemMsr"), "Weight")
>
>I get a runtime error "Value cannot be null."
>
>Does the "MemMsr" datarelation name contains the relation fields only or it has also all the child fields?
>
>
>>Ahmad,
>>
>>You need to bind the controls that contain the fields from the child table by binding to the relation instead of the child table:
>>
>>
>>Me.txtWeight.DataBindings.Add("Text", myDS.Member.MemMsr, "Weight")
>>
>>
>>>Yes,
>>>
>>>I am using TabPages, first have the "member" info, second have the DataGrid & a form, when the user clicks on the datagrid rows the information for that row will be displayed in the binded texbox in the same form, to get it more clear go to this address and click on "Screen Image 1" which have the main member info "Master" & click on the "Screen Image 2" where it has the datagrid & the binded texboxs: http://www.adsc.net/cms.html
>>>
>>>
>>>
>>>>I am unclear about what you mean by "spoiled". Are you running two different forms? Databinding is linked to a form.
>>>>
>>>>>I removed the DataSource property, but it's not effecting the spoiled binding.
>>>>>
>>>>>Why the binding not effecting the binded texbos's when I navigate the datagrid?
>>>>>
>>>>>
>>>>>>You shouldn't set the DataSource property and call the SetDataBinding method. The SetDataBinding method is how you set the DataSource and DataMember of the DataGrid at runtime. You are setting it in code so it is not necessary to use this method.
>>>>>>
>>>>>>>Hi Cathi,
>>>>>>>
>>>>>>>I fixed the datarelation problem. But it’s spoiling my databinding, when I add this line to my datagrid:
>>>>>>>Me.dgMeasurements.SetDataBinding(myDS, "Member.MemMsr")
>>>>>>>
>>>>>>>This is the code, I think I am missing somethign some where??
>>>>>>>
>>>>>>>
>>>>>>>myDA.Fill(myDS, "Member")
>>>>>>>myMeasureDA.Fill(myDS, "Measure")
>>>>>>>
>>>>>>>‘ Add DataRelation the DataSet
>>>>>>>myDS.Relations.Add("MemMsr", myDS.Tables("Member").Columns("MemberID"), myDS.Tables("Measure").Columns("MemberID"))
>>>>>>>
>>>>>>>' cbSelect Member DataSource
>>>>>>>Me.cbSelect.DataSource = myDS.Tables("Member")
>>>>>>>Me.cbSelect.DisplayMember = "MemberID"
>>>>>>>
>>>>>>>‘ Bind data in the first window form
>>>>>>>Me.txtMemberName_e.DataBindings.Add("Text", myDS.Tables("Member"), "Name_e")
>>>>>>>
>>>>>>>Me.dgMeasurements.DataSource = myDS.Tables("Measure")
>>>>>>>
>>>>>>>‘ the next line is spoiling my next databinding
>>>>>>>Me.dgMeasurements.SetDataBinding(myDS, "Member.MemMsr")
>>>>>>>
>>>>>>>‘ bind the 2nd window form (*** this binding get spoiled ***)
>>>>>>>Me.txtWeight.DataBindings.Add("Text", myDS.Tables("Measure"), "Weight")
>>>>>>>Me.txtHeight.DataBindings.Add("Text", myDS.Tables("Measure"), "Height")
>>>>>>>
>>>>>>>Thanks for the help
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform