CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 9/22/2003 2:11:00 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 24 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
tuckerak
Asp.Net User
Custom Control With Two Data Sources9/22/2003 2:11:00 PM

0/0

I am building a custom control that has two data lists and two image buttons. Both data lists need to be data bound, and the image buttons will be used to move items between the data lists. I have successfully bound the same data source to both data lists; however, I need the data source to be different for each data list. I have created 4 new properties for the second data source:

DataSource2
DataMember2
DataTextField2
DataValueField2

The first list box is bound successfully, but I receive an 'is neither a DataColumn nor a DataRelation for table Buckets.' error when binding with the second data source. Is it possible to use two different data sources in this way? Any advice is much appreciated.


Imports System.ComponentModel
Imports System.Web.UI
Imports System
Imports System.Web
Imports System.Collections
Imports System.Data
Imports System.Web.UI.WebControls
Imports System.Xml

Namespace myControls

Public Class DualListBox
Inherits Control
Implements INamingContainer

Private _dataSource As Object
Private _dataSource2 As Object
Private _dataMember As String = String.Empty
Private _dataMember2 As String = String.Empty
Private _dataValueField As String = String.Empty
Private _dataValueField2 As String = String.Empty
Private _dataTextField As String = String.Empty
Private _dataTextField2 As String = String.Empty

Public Property DataSource() As Object
Get
Return _dataSource
End Get
Set(ByVal Value As Object)
_dataSource = Value
End Set
End Property

Public Property DataSource2() As Object
Get
Return _dataSource2
End Get
Set(ByVal Value As Object)
_dataSource2 = Value
End Set
End Property

Public Property DataMember() As String
Get
Return _dataMember
End Get
Set(ByVal Value As String)
_dataMember = Value
End Set
End Property

Public Property DataMember2() As String
Get
Return _dataMember2
End Get
Set(ByVal Value As String)
_dataMember2 = Value
End Set
End Property

Public Property DataValueField() As String
Get
Return _dataValueField
End Get
Set(ByVal Value As String)
_dataValueField = Value
End Set
End Property

Public Property DataValueField2() As String
Get
Return _dataValueField2
End Get
Set(ByVal Value As String)
_dataValueField2 = Value
End Set
End Property

Public Property DataTextField() As String
Get
Return _dataTextField
End Get
Set(ByVal Value As String)
_dataTextField = Value
End Set
End Property

Public Property DataTextField2() As String
Get
Return _dataValueField2
End Get
Set(ByVal Value As String)
_dataValueField2 = Value
End Set
End Property

Private Function GetDataSource(ByVal DataSource, ByVal DataMember) As IEnumerable
If TypeOf DataSource Is IEnumerable Then
Return DataSource
ElseIf TypeOf DataSource Is DataSet Then
If DataMember <> String.Empty Then
Return DataSource.Tables(DataMember).DefaultView()
Else
Return DataSource.Tables(0).DefaultView()
End If
Else
Throw New ArgumentException("Invalid data source!")
End If
End Function

Protected Overrides Sub OnDataBinding(ByVal e As EventArgs)
If Not DataSource Is Nothing Then
Dim objDataEnum As IEnumerator
Dim lstListBox As ListBox

Controls.Clear()
ClearChildViewState()

objDataEnum = GetDataSource(_dataSource, _dataMember).GetEnumerator()

lstListBox = CType(Me.FindControl("lstAvailable"), ListBox)

While (objDataEnum.MoveNext())
lstListBox.Items.Add(New ListItem(objDataEnum.Current(_dataTextField).ToString, objDataEnum.Current(_dataValueField).ToString))
End While

objDataEnum = Nothing
lstListBox = Nothing

objDataEnum = GetDataSource(_dataSource2, _dataMember2).GetEnumerator()
lstListBox = CType(Me.FindControl("lstUsed"), ListBox)

While (objDataEnum.MoveNext())
lstListBox.Items.Add(New ListItem(objDataEnum.Current(_dataTextFieldB).ToString, objDataEnum.Current(_dataValueFieldB).ToString))
End While
End If
End Sub

Protected Overrides Sub CreateChildControls()
Dim lstListBox As ListBox
Dim ibtnButton As ImageButton

Me.Controls.Add(New LiteralControl("<table width=""400"" border=""0"" " & _
"cellspacing=""0"" cellpadding=""0"">"))
Me.Controls.Add(New LiteralControl("<tr>"))
Me.Controls.Add(New LiteralControl("<td width=""190"">"))
lstListBox = New ListBox()
lstListBox.ID = "lstAvailable"
lstListBox.Rows = 10
lstListBox.Width = Unit.Pixel(190)
lstListBox.Attributes.Add("Style", "color:Black;background-color:White;font-family:Arial,Helvetica,sans-serif;font-size:12px;")
Me.Controls.Add(lstListBox)
Me.Controls.Add(New LiteralControl("</td>"))
Me.Controls.Add(New LiteralControl("<td width=""20"" align=""center"" valign=""middle"">"))
ibtnButton = New ImageButton()
ibtnButton.ID = "ibtnAdd"
ibtnButton.ImageUrl = "/images/DualListBoxAddArrow.gif"
Me.Controls.Add(ibtnButton)
Me.Controls.Add(New LiteralControl("<br><br>"))
ibtnButton = New ImageButton()
ibtnButton.ID = "ibtnRemove"
ibtnButton.ImageUrl = "/images/DualListBoxRemoveArrow.gif"
Me.Controls.Add(ibtnButton)
Me.Controls.Add(New LiteralControl("</td>"))
Me.Controls.Add(New LiteralControl("<td width=""190"">"))
lstListBox = New ListBox()
lstListBox.ID = "lstUsed"
lstListBox.Rows = 10
lstListBox.Width = Unit.Pixel(190)
lstListBox.Attributes.Add("Style", "color:Black;background-color:White;font-family:Arial,Helvetica,sans-serif;font-size:12px;")
Me.Controls.Add(lstListBox)
Me.Controls.Add(New LiteralControl("</td>"))
Me.Controls.Add(New LiteralControl("</tr>"))
Me.Controls.Add(New LiteralControl("</table>"))
End Sub
End Class
End Namespace
tuckerak
Asp.Net User
Re: Custom Control With Two Data Sources9/22/2003 4:33:01 PM

0/0

*Beats head against desk*

No worries. I found the problem. I was assigning the DataTextField2 property the wrong value. It's amazing how you con look at something 1000 times and still miss a problem as simple as this. Very frustrating.
Andy Smith
Asp.Net User
Re: Custom Control With Two Data Sources9/22/2003 11:52:36 PM

0/0

It looks like you are implementing something I already offer for free on metabuilders.
my DualList control.
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ADO.NET 2: Programming with SQL Server 2005, Oracle, and MySQL Authors: Wallace B. McClure, Gregory A. Beamer, John J. Croft, John J. Croft, IV, J. Ambrose Little, Bill Ryan, Phil Winstanley, David Yack, Jeremy Zongker, Pages: 614, Published: 2005
Beginning InfoPath 2003 Authors: F. Scott Barker, Pages: 384, Published: 2005
Essential ASP. NET with Examples in C#: With Examples in C# Authors: Fritz Onion, Pages: 393, Published: 2003
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006
Windows Forms Programming in C# Authors: Chris Sells, Pages: 681, Published: 2004
ASP.NET Unleashed: unleashed Authors: Stephen Walther, Pages: 1488, Published: 2003
Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter Kit: visual web developer 2005 express edition starter kit Authors: David Sussman, Alex Homer, Pages: 312, Published: 2005
Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006
Beginning ASP.NET 2.0 Databases: Beta Preview Authors: John Kauffman, Thiru Thangarathinam, Pages: 427, Published: 2005
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005

Web:
CoDe Magazine - Article: Drag Once DataBinding with Custom Controls Changing the Controls. In the Data Sources Window, select any of the nodes in the TreeView. ... Page 1: Drag Once DataBinding with Custom Controls ...
Making Connections: Binding Controls to Custom Data Sources in .NET Many controls work with object collections as data sources. For data binding purposes, you can define a collection by the interfaces it supports. Two ...
ControlBuilderFAQ - Show FAQ - Custom parameters for data sources Custom parameters for data sources by Eilon Lipton, 1/31/2006 11:28:40 PM. As the author of the SqlDataSource and ObjectDataSource controls, ...
CodeProject: Implementing complex data binding in custom controls ... If you bind more than one control at the same data source (for example, ... for complex data binding ( DataGrid , DataGridView , BindingSource ) has two ...
Custom Data Binding, Part 2 As you've probably deduced by now, our custom list data source needs to broadcast .... As shown in the code sample above, notifying bound controls requires ...
Inside Microsoft: Implementing Data Binding in a Custom Server Control To implement simple data binding within your custom control, .... If the data source is not to be used during child control creation, two values are ...
15 Seconds : Building ASP.NET User and Server Controls, Part 2 Tomasz Kaszuba shows how to build and implement a custom pager for different controls that change depending on the data source or presentation. ...
Custom Controls: Weather control: Part 2 – The Slider Aug 12, 2008 ... This allows tracking changes in the data and updating the control. .... The control has two buttons to control the movement. ...
Creating a Custom Data Field Control - Part 2: ASP Alliance The following examples are consumers of this custom data field class described above. ... method binds the control with data in the underlying data source. ...
ASP.NET DataGrid Paging Part 2 - Custom Paging With custom paging, you control how many records are returned from the data source. The DataGrid displays rows zero (0) through one less than the PageSize ...

Videos:
HRBE: Holonomic Robot Bluetooth Environment Video of UCSB final B.S. Computer Engineer project (ECE 189) in Spring 2006. Team members Zach Davis, Kevin Deegan, Kurt Kiefer, and Don Shelton ...
(888)FITN.Org_Microsoft_Office_Accounting_MOAX ... (888)FITN.Org_Microsoft_Office_Accounting_MOAX.Org_Backup_Data_Utilities_General_Ledger Customer Inventory Pricing Receipts & Adjustments ...
(888)FITN.Org_Forensic_IT_Information_Technology_Video_18_ ... (888)FITN.Org_Forensic_IT_Information_Technology_Networks_MS_Office_Accounting_Backup_Data_Utilities_General_Ledger Prof1 http://www2.bus.miami ...
(888)FITN.Org_Forensic_IT_Information_Technology_Net ... (888)FITN.Org_Forensic_IT_Information_Technology_Networks_MS_Office_Accounting_Backup_Data_Utilities_General_Ledger Prof1 http://www2.bus.miami ...
(888)FITN.Org_Forensic_IT_Information_Technology_Video_13_ ... (888)FITN.Org_Forensic_IT_Information_Technology_Networks_MS_Office_Accounting_Backup_Data_Utilities_General_Ledger Prof1 http://www2.bus.miami ...
GeoServer and Architectures of Participation for Geospatial ... Google TechTalks August 23, 2006 Chris Holmes ABSTRACT This talk will introduce GeoServer, an open source server to publish and edit ...
The Archimedes Palimpsest Google TechTalks March 7, 2006 Will Noel Roger L. Easton, Jr. Michael B. Toth ABSTRACT The Archimedes Palimpsest is a 10th Century ...
(888)CPE1.Org_Microsoft_Office ... Windows SharePoint Services Version Comparison Summary Windows SharePoint Services is a versatile Windows Server technology that organizations ...
(888)FITN.Org_Forensic_IT_Information_Technology_Video_11_ ... (888)FITN.Org_Forensic_IT_Information_Technology_Networks_MS_Office_Accounting_Backup_Data_Utilities_General_Ledger Prof1 http://www2.bus.miami ...
(888)FITN.Org_Forensic_IT_Information_Technology_Video_04_ ... (888)FITN.Org_Forensic_IT_Information_Technology_Networks_MS_Office_Accounting_Backup_Data_Utilities_General_Ledger Prof1 http://www2.bus.miami ...




Search This Site:










master page selection - option missing

layout problem (design)

bug using option strict on in asp.net 2.0 app

how do i access my web service during development from outside localhost

remotely check out and check via vs2005

differences between visual studio 2005 product versions (standard, pro, academic)

vs 2005 editions

does visual studio.net 2005 run ok on xp home

viewing the other part of the page partial class

vs 2k5 asp.net 2.0 beta 2 migration problem

runtime performance

lost search field in editor toolbar

software configuration management portal

coding on mac

visual studio 2005 invalid search path

error in web.config after building in asp.net 2.0 final

work items tracking from team foundation server?

radiobuttonlist withing datalist

new class file not found by other files and no intellisense

design-time vs. run-time

how to enable intellisense of my custom server controls

ms expressions web - does it help?

devenv.exe+problem

file name(danish/latin) has been changed on download popup form of internet explorer

textbox populated from javascript does not retain values during postback (vs 2005)

page throwing nt login/pwd window

problems installing vs 2005 pro. instmsiw.exe

code an updated date for a hyperlink

making website debugging work again

nhibernate (please reply)

  Privacy | Contact Us
All Times Are GMT