Bind a Textbox to a Datarow?

I want to bind a textbox to a datarow.  I tried:

txtStrNo.DataBindings.Add(New Binding("Text", drResult , "strStructureNo"))
and
txtStrNo.DataBindings.Add("Text", drResult , "strStructureNo")

and I get a SystemArgumentException

By the way, I'm working in .NET Compact Framework 1.0 in VB (obviously!)

Thanks.
gerrystratAsked:
Who is Participating?
 
RejojohnyCommented:
i do not think u can bind a datarow .. u can bind a dataset or probably even a datatable. .

ur code shoud be
txtStrNo.DataBindings.Add(New Binding("Text", UrDataset , "UrDatatable.ColumnName"))

The above statement will work .. the one below i am not too sure .. but u could give it a try
txtStrNo.DataBindings.Add(New Binding("Text", UrDataTable, "ColumnName"))


0
 
rafranciscoCommented:
Will this work?

txtStrNo.Text = drResult["strStructureNo"].ToString()
0
 
tusharashahCommented:
a bit modification on above syntax, get value like following:

While drResult.Read
    txtStrNo.Text = drResult("strStructureNo").ToString            'where strStructureNo is DataBase Field name
End

drResult.Close

-tushar
0
 
gerrystratAuthor Commented:
That will assign the value to the textbox, but it won't actually bund the textbox to the field, right?  Changes in the textbox won't be reflected in the datarow.
0
 
gerrystratAuthor Commented:
Ok, thanks.  I don't think you can bind it either.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.