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

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
DataGridTextBoxColumns. 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 1771
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
DataGridTextBoxColumns. 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******@dtgnet.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.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
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...
0
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...
2
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...
3
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...
2
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
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...
3
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...
0
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...
5
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...
16
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.