473,770 Members | 5,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding an ArrayList to a datagrid

Hi,

I am having the same problem I had a while back with a windows app but
now in a web application. I need to take the results of a data query
and dump them into an arraylist. I then need to bind that array list
into a datagrid in my web app. It works fine, but the columns are out
of order.

I solved this in my windows application by using
DataGridTextBox Columns. However, I cannot find an equivalent in my web
application. I tried to create a Bound Column to solve this issue, but
it caused another one - in the sense that it caused two columns for
every one column I needed.

How is this typically done?

Nov 7 '06 #1
4 1787
Doug,

If you are using DataGrid I assume that means you are using ASP.NET
1.1. In ASP.NET 2.0 the GridView control replaces the DataGrid and
provides some helpful support to organize your data columns.

See here...

http://www.asp.net/learn/dataaccess/....aspx?tabid=63

In your case, it sounds like you are automatically having the columns
generated. You can turn that off in the Properties panel and add the
columns in the order you like.

Brennan Stehling
http://brennan.offwhite.net/blog/

Doug wrote:
Hi,

I am having the same problem I had a while back with a windows app but
now in a web application. I need to take the results of a data query
and dump them into an arraylist. I then need to bind that array list
into a datagrid in my web app. It works fine, but the columns are out
of order.

I solved this in my windows application by using
DataGridTextBox Columns. However, I cannot find an equivalent in my web
application. I tried to create a Bound Column to solve this issue, but
it caused another one - in the sense that it caused two columns for
every one column I needed.

How is this typically done?
Nov 7 '06 #2
In your case, it sounds like you are automatically having the columns
generated. You can turn that off in the Properties panel and add the
columns in the order you like.
So I'd have to do it in code? There's no way to do it dynamically?

Nov 7 '06 #3
Doug,

There are a load of options for playing with columns. Sounds like you just
need templatecolumns set up, or boundcolums with autogenerate false set as
Brennen suggested, and that can be set as a property of the datagrid
declaration.

http://samples.gotdotnet.com/quickst..._datagrid.aspx

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Doug" <dn******@dtgne t.comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
>
>In your case, it sounds like you are automatically having the columns
generated. You can turn that off in the Properties panel and add the
columns in the order you like.

So I'd have to do it in code? There's no way to do it dynamically?

Nov 7 '06 #4
or boundcolums with autogenerate false set as Brennen suggested, and that can be set as a property of the >datagrid declaration.

Thanks! I misunderstood what Brennen was suggesting, but I figured it
out now and it's working great! Thank you!

Nov 8 '06 #5

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

Similar topics

1
1443
by: Jordan | last post by:
After binding an arraylist to a datagrid, is it possible to allow the user to add and delete new rows on the datagrid just as they would if a datatable were bound to the control? I have tried to implement some interfaces but nothing has been successful so far, thanks in advance, Jordan
0
1695
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I then add a DataGridTextBoxColumn for each of the properties in my custom class which define a MappingName --> property name in class as well as header text. When I run the form, I see correct number of rows displayed, but none of the columns...
2
4244
by: John Sun | last post by:
Hi, Dear gurus, I want to bind my collection to a datagrid. The field names in my object show up in a weird order, and I just wonder how I could reorder those columns . I find some code like the following , but I don't want to do it that way because it won't work if I have large number of fields.
3
5936
by: Rami | last post by:
Hey, I Tried to bind a DataGrid to an ArrayList, and had 2 problems: 1. The DataGrid shows the Length property of the items instead of their text - how can I change that? 2. After binding, I add new elements to the ArrayList but the DataGrid doesnt refresh's it's view - I have to set the DataSource property of the DataGrid to null and then re bind it to the ArrayList! Isnt there a "pretier" way? Thanks ahead
2
1973
by: kids_pro | last post by:
I created a simple Person class as following: class Person{ private string fname; private string lname; public Person(string fname, string lname){ this.fname = fname; this.lname = lname; }
5
1225
by: Alex Nitulescu | last post by:
Hi. I'm fighting the following code: __________________________________________________________________________ a. I have a class UserInfo.vb: <Serializable()> Public Class UserInfo Public Username As String Public Password As String Public Email As String End Class
3
1585
by: Jim Bancroft | last post by:
Hi everyone, I'm binding an ArrayList to a DataGrid for the first time (I'm used to binding DataSets and DataTables) and I was wondering if I could somehow "name" the ArrayList, so that I can refer to it as a DataField in an asp:BoundColumn? In essence, I'm doing this: ArrayList Arr1 = new ArrayList();
0
229
by: guy | last post by:
I have a winforms datagrid bound to an arraylist which works correctly, however if I add a row to the arraylist i cannot get the datagrid to display the updated data other than by:- clearing the dg bindings binding the dg to a DIFFERENT arraylist clearing the dg bindings binding the dg to the correct arraylist there must be an easy way, any ideas?
5
4869
by: Rami | last post by:
Hey, I Tried to bind a DataGrid to an ArrayList, and had 2 problems: 1. The DataGrid shows the Length property of the items instead of their text - how can I change that? 2. After binding, I add new elements to the ArrayList but the DataGrid doesnt refresh's it's view - I have to set the DataSource property of the DataGrid to Nothing and then re bind it to the ArrayList! Isnt there a "pretier" way? Thanks ahead
16
5313
by: Michael C# | last post by:
I'm binding a Combobox to an Arraylist, and I'd like to set the ValueMember and DisplayMember properties of the Combobox. Is this possible, or do I need to bind to a DataTable? Thanks
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10053
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9867
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...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
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
6676
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
5312
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
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.