473,405 Members | 2,310 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,405 software developers and data experts.

Problem in Binding ArrayList to a dataGrid

3
Hi all,

i created an array list & i filled it with set of objects & then bind it to a data grid
but the problem is that the data grid appear with no data,did anyone has a solution for this problem?
Sep 21 '07 #1
3 896
emansc
3
Hi all,

i created an array list & i filled it with set of objects & then bind it to a data grid
but the problem is that the data grid appear with no data,did anyone has a solution for this problem?
the following is the code which i write
ArrayList al = new ArrayList();
al.Add(new UserAccount("0122", "Emo", "online", "false"));
dg1.DataSource = al;
dg1.DataBind();
Sep 21 '07 #2
the following is the code which i write
ArrayList al = new ArrayList();
al.Add(new UserAccount("0122", "Emo", "online", "false"));
dg1.DataSource = al;
dg1.DataBind();

Hi
I dont know abt User Account in this context
I think the problem is there

My code is take as example

SqlConnection conn = new SqlConnection(_connection);
conn.Open();
ArrayList al = new ArrayList();
SqlDataAdapter da = new SqlDataAdapter("DynamicSearch_Keywords", conn);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add("@Search_Keyword", "a");
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow dr in ds.Tables[0].Rows)
foreach (DataColumn dc in ds.Tables[0].Columns)
{
al.Add(dr[dc].ToString());
}

GridView1.DataSource=al;
GridView1.DataBind();


i tried also this

ArrayList al1 = new ArrayList();
al1.Add("0122");
al1.Add("01234");
al1.Add("012345");

GridView1.DataSource=al1;
GridView1.DataBind();


All r working
Sep 21 '07 #3
Plater
7,872 Expert 4TB
Generally speaking, you need a much more involved object to act as a datasource.
Try using a DataTable instead or an ArrayList?
Sep 21 '07 #4

Sign in to post your reply or Sign up for a free account.

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...
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; }
3
by: Matthew Woods | last post by:
Hi, is there any way to format and order the columns displayed in a datagrid bound to a class that inherits from IBindingList? i have used DataGridTableStyle and added DataGridTextBoxColumns to it...
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...
6
by: guy | last post by:
I have a datagrid with tablestyles and columnstyles set up using the designer, there are 4 columns, bount to 4 of the properties of an object held in an arraylist the binding works fine, the...
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
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:
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...
0
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...
0
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,...
0
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...

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.