Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dataset
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Miscellaneous
Thread ID:
00722613
Message ID:
00725728
Views:
16
>Hi BOb,
>
>By assiging values of controls from the code-behind file, directly into the control's text property, keeps the code out of the UI file. Databinding in the UI can make reading code difficult and spread out. By using a method in the code-behind that is responsible for binding the data to the controls, makes the maintenance of the App much easier.

Hmm... i didn't consider this the difference of where the code is. I guess I am just spoiled with VFP and data binding. So, what I consider databinding is that if I bind a control to a field, then changing the value of the control changes the field. But it Kevins book, as you know sice you tech edited it, for web pages he does something like:

this.txtLastName.Text = dr["lastname"].ToText();

Then, in the update he does the reverse:

dr["lastname"] = this.txtLastName.Text;

So, in my mind that isn't data binding... or is that all you get in web forms? Or, maybe he is doing this cause he is using business objects rather than dropping a SQLConneciton and SQLAdapter objects on the design surface?

Thanks,
BOb


>
>>Bonnie,
>>
>>In a web form, what does databinding give you over assigning a value from the dataset to the .Text property of the control?
>>
>>Perhaps I should ask Keven McNiesh, this is the method he uses in his book, although he says he is data binding.
>>
>>>Hi Ahmad,
>>>
>>>I've been away at WhilFest, that's why I haven't replied sooner.
>>>
>>>Two things:
>>>
>>>1) The way you're assigning your data to the text box will work, but you really don't want to do it this way. You really need to get data binding working correctly, as in my previous replies to you. Part of the reason you may getting run-time errors when you try it is that I may have gotten the VB syntax wrong. Someone who knows VB may have to jump in here and help out.
>>>
>>>2) Your update to the backend is not working because you need to do the da.Update() before you do the AcceptChanges(). AcceptChanges() marks all the changes in the dataset as not being changed anymore, and so the da.Update() thinks that there is nothing to be updated.
>>>
>>>HTH,
>>>~~Bonnie
>>>
>>>
>>>>Hi Bonnie,
>>>>
>>>>I found another way and hope it's correct..
>>>>I created a DataRow object:
>>>>
>>>> For Each myDR In myDS.Tables("Bank").Rows
>>>> Next
>>>>
>>>>Then assign my form textbox to the fiels:
>>>> Me.txtBankName_e.Text = Trim(myDR("bankname_e"))
>>>>
>>>>But stuck in 2 things:
>>>>1. Could not assign the myDS to my combo box ( Me.cbSelect.DataSource = myDS)
>>>>
>>>>2. Could not update the dataset with the modified data :
>>>> myDR.BeginEdit()
>>>> myDR("bankname_e") = Me.txtBankName_e.Text
>>>> myDR.EndEdit()
>>>> myDR.AcceptChanges()
>>>> myDA.Update(myDS, "bank")
>>>>
>>>>
>>>>So what do you think?
>>>>
>>>>
>>>>
>>>>>Hi Ahmad,
>>>>>
>>>>>First you need to databind your textbox (and I hope I get the VB syntax right):
>>>>>
>>>>>me.DataBindings.Add("Text", MyTable, "MyColumn")
>>>>>
>>>>>Then, you use the Position property of the BindingContext to navigate the rows:
>>>>>
>>>>>-- nRow is an integer, specifying which row of the DataSet you are on.
>>>>>me.BindingContext(MyTable).Postion = nRow
>>>>>
>>>>>
>>>>>HTH,
>>>>>~~Bonnie
>>>>>
>>>>>
>>>>>
>>>>>>Hi All,
>>>>>>
>>>>>>I succeeded to create my DataSet & DataAdapter:
>>>>>>Dim myDS As New DataSet()
>>>>>>Dim myDA As New SqlClient.SqlDataAdapter("Select * From AN_Bank", myConn.oConnection)
>>>>>>myDA.Fill(myDS, "MyTable")
>>>>>>
>>>>>>- But stuck in retrieving the table rows and assigning the table fields to my form TextBox
>>>>>>
>>>>>>- How record Louck in handeled in MS-MSDE?
>>>>>>
>>>>>>Can anyone help please?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform