473,780 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When you bind an array to a datagrid, what's the field name?

AFN
In VB.NET, I can successfully bind a generic datagrid to a 1 dimensional
array. But, now I want to add a button column, and so I think I need to
make the first column (the one having data in the array) a "BoundColum n" and
the 2nd column my button column. The problem is that the BoundColumn wants
a DataField name. There is none! So how do I bind this one column to the
array column when the array doesn't have column names? And if your answer
is to put column names in my array, please tell me how.
Nov 18 '05 #1
3 1951
Why didn't you just test this on a new page? It looks like the answer you
are looking for is "Item"

'Test
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim test() As String = New String() {"one", "two", "three", "four",
"five"}
Me.DataGrid1.Da taSource = test
Me.DataGrid1.Da taBind()
End Sub

'Results
Item
one
two
three
four
five

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:BA******** *********@twist er.socal.rr.com ...
In VB.NET, I can successfully bind a generic datagrid to a 1 dimensional
array. But, now I want to add a button column, and so I think I need to
make the first column (the one having data in the array) a "BoundColum n"
and
the 2nd column my button column. The problem is that the BoundColumn
wants
a DataField name. There is none! So how do I bind this one column to
the
array column when the array doesn't have column names? And if your
answer
is to put column names in my array, please tell me how.

Nov 18 '05 #2
AFN
I did test that. And I also saw the column name it creates of "Item", but
if you try to bind to "Item" it fails. "Item" is the name it gives to the
header but not really the column name.
"Jared" <VB***********@ email.com> wrote in message
news:10******** *****@corp.supe rnews.com...
Why didn't you just test this on a new page? It looks like the answer you
are looking for is "Item"

'Test
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim test() As String = New String() {"one", "two", "three", "four",
"five"}
Me.DataGrid1.Da taSource = test
Me.DataGrid1.Da taBind()
End Sub

'Results
Item
one
two
three
four
five

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:BA******** *********@twist er.socal.rr.com ...
In VB.NET, I can successfully bind a generic datagrid to a 1 dimensional
array. But, now I want to add a button column, and so I think I need to make the first column (the one having data in the array) a "BoundColum n"
and
the 2nd column my button column. The problem is that the BoundColumn
wants
a DataField name. There is none! So how do I bind this one column to
the
array column when the array doesn't have column names? And if your
answer
is to put column names in my array, please tell me how.


Nov 18 '05 #3
I see what you mean, try using a custom class, you can use either a
collection or an arraylist.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim Items As New Collection
For counter As Integer = 1 To 10
Dim Item As New MyItems
Item.Item = "Item: " & counter
Items.Add(Item)
Next
Me.DataGrid1.Da taSource = Items
Me.DataGrid1.Da taBind()
End Sub

Private Class MyItems
Dim mItem As String
Public Property Item() As String
Get
Return mItem
End Get
Set(ByVal Value As String)
mItem = Value
End Set
End Property
End Class
"AFN" <DE************ ************@ya hoo.com> wrote in message
news:Rn******** ********@twiste r.socal.rr.com. ..
I did test that. And I also saw the column name it creates of "Item", but
if you try to bind to "Item" it fails. "Item" is the name it gives to the
header but not really the column name.
"Jared" <VB***********@ email.com> wrote in message
news:10******** *****@corp.supe rnews.com...
Why didn't you just test this on a new page? It looks like the answer you
are looking for is "Item"

'Test
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim test() As String = New String() {"one", "two", "three", "four",
"five"}
Me.DataGrid1.Da taSource = test
Me.DataGrid1.Da taBind()
End Sub

'Results
Item
one
two
three
four
five

"AFN" <DE************ ************@ya hoo.com> wrote in message
news:BA******** *********@twist er.socal.rr.com ...
> In VB.NET, I can successfully bind a generic datagrid to a 1
> dimensional
> array. But, now I want to add a button column, and so I think I need to > make the first column (the one having data in the array) a
> "BoundColum n"
> and
> the 2nd column my button column. The problem is that the BoundColumn
> wants
> a DataField name. There is none! So how do I bind this one column to
> the
> array column when the array doesn't have column names? And if your
> answer
> is to put column names in my array, please tell me how.
>
>



Nov 18 '05 #4

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

Similar topics

8
7933
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the same control. Is there anyone who has tried this before and knows why this is hapenning ??
0
2833
by: Jim French | last post by:
I have a page that takes a comma delimited string and needs to bind to a Repeater control. The string is split into an Array, and each value is put into a DataBase query via a For Each loop. The purpose is to retrieve address information for the user. Sometimes, the address_fk field in the people table is null, so there will be no linking address information. In this case, the section to be displayed asks if the user would like to create...
1
2490
by: Jim Hammond | last post by:
How can one bind a database image column (the byte array - not the path) to a datagrid column? The closest thing I have found so far is this January 2002 statement by Dino Esposito: "Likewise, an image column could be adapted to load the bits, and not the path, of the image directly from a blob database field. I'll reserve this particular topic for a future column."
4
4091
by: Greg Linwood | last post by:
I am wondering what the best approach to binding XML data to an asp:Table from the Page_Load event in a code behind module? I'm using VB.Net and initially approached this by adding a table to the web page from the VS2003 ASP page designer, extracting an XML document from SQL Server during Page_Load, then adding asp:TableRows & asp:TableCells one at a time / loading the corresponding xml values a cell at a time. Is there a better (less...
3
2327
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and bind that to the datagrid? I have never done either (usually I get a recordset from a stored procedure and bind results directly). I also don't know which is faster. Whichever you suggest, can you give a couple lines of sample code? Thank...
2
1694
by: ringo | last post by:
I've come accross an interesting problem populating an asp.net datagrid. I am trying to bind XML data to a datagrid as I've done in countless other applications, the only difference this time being that the XML I'm getting has attributes within the elements which I need to bind to the grid. Example XML (I need to populate the datagrid with the address, name, and CityStateZip elements): <properties> <record display="properties" no="1">...
7
2563
by: Jed | last post by:
I have a web service method that returns an array of custom objects marked serializeable with fully described public properties. When I bind the results to a DataGrid I can access the properties in the ItemDataBound event of the codebehind but I can't access them declaratively in the HTML code? Here is the code to call the method. net.mysite.www.WSInterface proxy; proxy = new net.mysite.www.WSInterface();
14
2132
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these grid and write to the database and I set the new Primary Keys and related Fields to the new asigned atuonumbers in the Access.
3
1523
by: Microsoft | last post by:
I am able to set the datasource of a datagrid as a simple array, but on the form it only displays the length of the strings in the array. Not the actual items in the string. Dim lastpatch As String() for loop that adds text to the array lastpatch(i) = result40 end loop
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9931
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.