PC Review


Reply
Thread Tools Rate Thread

ADO.NET and ASP.NET DataBinding

 
 
Lloyd Sheen
Guest
Posts: n/a
 
      29th Jun 2004
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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs Microsoft ASP .NET 0 26th Sep 2007 12:54 AM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin Microsoft ASP .NET 1 12th Nov 2006 01:43 PM
Databinding Alan T Microsoft C# .NET 2 17th Jul 2006 05:08 PM
Databinding Henry Microsoft ADO .NET 3 21st Jul 2004 08:22 PM
Databinding Bible (REPOST FROM m.p.d.f.WindowsForms.Databinding) a Microsoft ADO .NET 1 16th Jul 2004 03:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:30 AM.