473,387 Members | 1,379 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,387 software developers and data experts.

Binding DataGrid to legacy COM object

I have an ActiveX dll written in VB6. It exposes a class called
CustomerDisplays, with a Public Function NewEnum (procedure ID -4,
hide this member), and a Public Function Item (default) and a Public
Function Count. IOW, this thing looks like an enumerable collection
of, in this case, CustomerDisplay objects. Each CustomerDisplay object
has, in turn, an lCustomerID as Long property and a sSortName as
String property. The CustomerDisplays objects works fine as an
enumberable collection in VB6, VBA, and VB.Net. Used it for years.

I am trying to build an asp.net page with a DataGrid control bound to
a CustomerDisplays object. My form code is shown below. When I run it,
I get an "Index was out of range" error on the line that references
Columns(0). The DataGrid isn't creating any columns.

Can someone tell me what I'm doing wrong? Is the correct way to bind a
DataGrid to a legacy COM component?

========code=================

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As
System.Web.UI.WebControls.DataGrid
Public moCustomerDisplays As WhsBusObjectsTLB.CustomerDisplays
Public moCustomerDisplay As WhsBusObjectsTLB.CustomerDisplay

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 Me.IsPostBack Then
moCustomerDisplays = New
WhsBusObjectsTLB.CustomerDisplays()
With Me.DataGrid1
.DataSource = moCustomerDisplays
.DataKeyField = "lCustomerID"
.AutoGenerateColumns = True
.DataBind()
.Columns(0).Visible = True
.Columns(1).Visible = True
End With
End If
End Sub

End Class
Nov 20 '05 #1
0 1365

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

Similar topics

0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
0
by: Shane O. Pinnell | last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a datagrid populated from a dataset. I have a...
1
by: reiks | last post by:
Do we any computed column for the datagrid? Do we any expression property for the datagrid columns? My requirement is I ought to bind the following expression at design time if(au_lname=="",'...
1
by: Harold | last post by:
Hi all, having a little difficulty binding up a dropdownlist control in a datagrid column. I know I must be missing something Here are 2 methods. One is the DataGrid's ItemDataBound event to catch...
11
by: Rourke Eleven | last post by:
I have looked and searched. What good is the databind property on Radiobuttons? How does one go about actually using it? What is a good resource on this? I understand that I can easily get/set...
8
by: Richard L Rosenheim | last post by:
I have a dataset containing a parent table related to a child table. The child table contains an ID field (which is configured as autonumber in the datatable), the ID of the parent, plus some...
6
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
0
by: Ausclad | last post by:
Hi all, I have a datagrid, which is bound to a datatable. In the datagrid, I have changed some of the fields to be combo boxes. In the datagrid I want to be able to allow the user to change...
1
by: Stephen Barrett | last post by:
I have an application that was originally built with ASP.Net 1.1. We finally got permission to migrate to 2.0. Due to time constraints we migrated the web projects to 2.0 web application...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.