473,404 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Is it possible to use ADO.NET and ASP.NET databinding with textboxes , HELP!

I have several apps that use a roll your own approach, but I am embarking on
a project which will not allow that with the time constraints.

I have gened up a little app to try the databinding approach. Simply it is
a page to maintain the Territories table in Northwind (SQL Server).

I have two SqlDataAdaptors - one for the list of Territories
- on for the individual
Territories row (uses parameter to select)

I created the two datasets. So far so good. I can open the page bind to a
dropdownlist, and get the details into a set of textboxes for each field.

Now I also have a button which simply outputs the text of the update
command. It uses the
UpdateCommand.CommandText from the dataset.

How does databinding help with updates. All parameter values are nothing
when I click the button?

The code follows:

Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.TerritoryList.Fill(Me.DSTerritoryList)
Me.DropDownList1.DataBind()
End If
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Me.OneTerritory.SelectCommand.Parameters(0).Value =
DropDownList1.SelectedItem.Value
Me.OneTerritory.Fill(Me.DsOneTerritory1)
Page.DataBind()
End Sub

Private Sub btnUpdateCommand_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdateCommand.Click
Me.txtUpdateCommand.Text = Me.OneTerritory.UpdateCommand.CommandText
End Sub
End Class


Nov 18 '05 #1
3 1381
1.) Persist the dataset by using the ViewState (not recommended) or serialize and
store the dataset on the hard disk or store the dataset in the session. What I
do is just re-run the code to re-fill the dataset from the database after a
postback.

2.) Once dataset is re-filled, you re-bind the dataset to the controls which need
it.

3.) You now have the data in the combo and the index of the item in the combo
box. All of the above should be done on Page_Load (Form_Load) and should be
ready for the Click event when it gets there.

Mythran
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:uA********************@twister01.bloor.is.net .cable.rogers.com...
I have several apps that use a roll your own approach, but I am embarking on
a project which will not allow that with the time constraints.

I have gened up a little app to try the databinding approach. Simply it is
a page to maintain the Territories table in Northwind (SQL Server).

I have two SqlDataAdaptors - one for the list of Territories
- on for the individual
Territories row (uses parameter to select)

I created the two datasets. So far so good. I can open the page bind to a
dropdownlist, and get the details into a set of textboxes for each field.

Now I also have a button which simply outputs the text of the update
command. It uses the
UpdateCommand.CommandText from the dataset.

How does databinding help with updates. All parameter values are nothing
when I click the button?

The code follows:

Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.TerritoryList.Fill(Me.DSTerritoryList)
Me.DropDownList1.DataBind()
End If
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Me.OneTerritory.SelectCommand.Parameters(0).Value =
DropDownList1.SelectedItem.Value
Me.OneTerritory.Fill(Me.DsOneTerritory1)
Page.DataBind()
End Sub

Private Sub btnUpdateCommand_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdateCommand.Click
Me.txtUpdateCommand.Text = Me.OneTerritory.UpdateCommand.CommandText
End Sub
End Class

Nov 18 '05 #2
Thanks but I am not sure what this would do for my problem. What I need is
to have a methodology of binding textboxes, making changes and having the
ability to click a button and have those changes update the database.

The dataadaptor has parameters in the updatecommand and how those parameters
would be updated with values is something I cannot figure out. Once I
rebind the dataset to the controls the updated info (that the user entered)
is lost.

Lloyd Sheen

"Mythran" <ki********@hotmail.com> wrote in message
news:up**************@TK2MSFTNGP11.phx.gbl...
1.) Persist the dataset by using the ViewState (not recommended) or serialize and store the dataset on the hard disk or store the dataset in the session. What I do is just re-run the code to re-fill the dataset from the database after a postback.

2.) Once dataset is re-filled, you re-bind the dataset to the controls which need it.

3.) You now have the data in the combo and the index of the item in the combo box. All of the above should be done on Page_Load (Form_Load) and should be ready for the Click event when it gets there.

Mythran
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message news:uA********************@twister01.bloor.is.net .cable.rogers.com...
I have several apps that use a roll your own approach, but I am embarking on a project which will not allow that with the time constraints.

I have gened up a little app to try the databinding approach. Simply it is a page to maintain the Territories table in Northwind (SQL Server).

I have two SqlDataAdaptors - one for the list of Territories
- on for the individual
Territories row (uses parameter to select)

I created the two datasets. So far so good. I can open the page bind to a dropdownlist, and get the details into a set of textboxes for each field.
Now I also have a button which simply outputs the text of the update
command. It uses the
UpdateCommand.CommandText from the dataset.

How does databinding help with updates. All parameter values are nothing when I click the button?

The code follows:

Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.TerritoryList.Fill(Me.DSTerritoryList)
Me.DropDownList1.DataBind()
End If
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Me.OneTerritory.SelectCommand.Parameters(0).Value =
DropDownList1.SelectedItem.Value
Me.OneTerritory.Fill(Me.DsOneTerritory1)
Page.DataBind()
End Sub

Private Sub btnUpdateCommand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateCommand.Click
Me.txtUpdateCommand.Text = Me.OneTerritory.UpdateCommand.CommandText
End Sub
End Class


Nov 18 '05 #3
I'll create a test project and send it to ya via email. Hope it helps ;)

Mythran
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:qH***************@news04.bloor.is.net.cable.r ogers.com...
Thanks but I am not sure what this would do for my problem. What I need is
to have a methodology of binding textboxes, making changes and having the
ability to click a button and have those changes update the database.

The dataadaptor has parameters in the updatecommand and how those parameters
would be updated with values is something I cannot figure out. Once I
rebind the dataset to the controls the updated info (that the user entered)
is lost.

Lloyd Sheen

"Mythran" <ki********@hotmail.com> wrote in message
news:up**************@TK2MSFTNGP11.phx.gbl...
1.) Persist the dataset by using the ViewState (not recommended) or

serialize and
store the dataset on the hard disk or store the dataset in the session.

What I
do is just re-run the code to re-fill the dataset from the database after

a
postback.

2.) Once dataset is re-filled, you re-bind the dataset to the controls

which need
it.

3.) You now have the data in the combo and the index of the item in the

combo
box. All of the above should be done on Page_Load (Form_Load) and should

be
ready for the Click event when it gets there.

Mythran
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in

message
news:uA********************@twister01.bloor.is.net .cable.rogers.com...
I have several apps that use a roll your own approach, but I am embarking on a project which will not allow that with the time constraints.

I have gened up a little app to try the databinding approach. Simply it is a page to maintain the Territories table in Northwind (SQL Server).

I have two SqlDataAdaptors - one for the list of Territories
- on for the individual
Territories row (uses parameter to select)

I created the two datasets. So far so good. I can open the page bind to a dropdownlist, and get the details into a set of textboxes for each field.
Now I also have a button which simply outputs the text of the update
command. It uses the
UpdateCommand.CommandText from the dataset.

How does databinding help with updates. All parameter values are nothing when I click the button?

The code follows:

Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.TerritoryList.Fill(Me.DSTerritoryList)
Me.DropDownList1.DataBind()
End If
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Me.OneTerritory.SelectCommand.Parameters(0).Value =
DropDownList1.SelectedItem.Value
Me.OneTerritory.Fill(Me.DsOneTerritory1)
Page.DataBind()
End Sub

Private Sub btnUpdateCommand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateCommand.Click
Me.txtUpdateCommand.Text = Me.OneTerritory.UpdateCommand.CommandText
End Sub
End Class



Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff | last post by:
I am having a behaviour problem with Databinding on a C# WinForm. I have three textboxes and a Checkbox bound to a dataset. The desired behaviour is when I check/uncheck the checkbox, I want to...
3
by: Nic | last post by:
Hey, I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>. Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but...
3
by: MajorTom | last post by:
Hello I need help. I have a datagrid that have a dataview as datasource. in the keyup event of one textbox I use dataview.rowfilter = some.text; when the condition of my rowfilter return...
7
by: Richard | last post by:
I have a form with seven tapages. These span only one record with a large number of fields (textboxes). On Tabpage1 I display a number of read-only text boxes. This displays information about...
0
by: optictygre | last post by:
Databinding with reflection I have a class, SmartString: Public Class SmartString ...Psuedo code follows Public Property Value() as String Return Me.Text
5
by: Uncle Sammy | last post by:
Hey all, I am trying to use a Listbox control with two data bindings. I cannot get the listbox to change the textboxes. Here's the code: using System; using System.Collections.Generic;...
0
by: bne | last post by:
Hi All, I have a shopping cart app that (I think) has broken due to an upgrade to .NET 2.0. Some products display fine: <http://ukweddinggroup.com/default.aspx?prd=11> Others display okay...
1
by: Pieter | last post by:
Hi, My problem: When the cursor is on a given row in the DataGridView, the data in the row has to be shown in TextBoxes underneath the DataGridView. the user must be able to edit in the...
4
by: John Wright | last post by:
I have set up a datagrid on my form with six columns. I want to capture the data from six textboxes on the form and add them to the datagrid. All the info I can find about this is with datatables...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.