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

how to bind an array of data to a datagrid?

Hi all! I got an array of datarows after a select on a datatable, I want
to show the results in datagrid, but it doesnt work, do i have to create
a dataview? Please help me out thank you IRNBRU

*** Sent via Developersdex http://www.developersdex.com ***
Feb 18 '06 #1
1 1369
Hi Irnbru,

You should use DataView. here is some sample code for you.

SqlCommand cmd = new SqlCommand();

SqlConnection con = new SqlConnection();

DataSet ds = new DataSet();
SqlDataAdapter adap = new SqlDataAdapter();

SqlDataReader rdr ;
con.ConnectionString = @"server=.;database=AdventureWorks;uid=sa;pwd=s a";

con.Open();

cmd.Connection = con;

cmd.CommandType = CommandType.Text;

cmd.CommandText = @"select LocationID,Name as LocNAme from
Production.Location";

adap.SelectCommand = cmd;

adap.Fill(ds, "ER");

DataRow[] dr = ds.Tables[0].Select();
dataGrid1.DataSource = dr[0].Table.DefaultView;

vinu


"irnbru irnbru" <le*********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi all! I got an array of datarows after a select on a datatable, I want
to show the results in datagrid, but it doesnt work, do i have to create
a dataview? Please help me out thank you IRNBRU

*** Sent via Developersdex http://www.developersdex.com ***

Feb 19 '06 #2

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

Similar topics

4
by: Michael Whittaker | last post by:
Hello! I have a problem with my php script. The script's task is to search an IP-Database with ranges as entries and find, in which range the entered IP is. OK, I've queried the MySQL-Results...
6
by: Ricardo Luceac | last post by:
Hi... My program make a select to an table and return the results to a datagrid, it's all ok with dataset, but in large tables it needs to get the entire table to show in datagrid and sometimes...
4
by: John Dalberg | last post by:
I noticed the starterkits timetracker & issue tracker load data from a database into custom collections (arraylists) which bind to a datagrid. What are the advantages of using custom collections...
0
by: Nick | last post by:
Hi, I have a Repeater control and want to bind a hyperlink to each repeated row. For this I can use the following syntax (excuse any incorrect naming but I don't have any code to hand): ...
0
by: Katit | last post by:
Hello, Probably very simple, but I can't bind array of typed objects to the ListBox When I specify DataTextField = "Description" I get error that property named "Description" doesn't exist, but...
8
by: iluvatar | last post by:
Hi all. How can I initialize an array data member in the "faster" way? For example, suppose I have a class like class Example{ private: double array; public: Example(const double & val0,...
2
by: Taha | last post by:
Hi All Can You please Explain To Me How Bind XML Data From WebService To Grid In Vb.Net Thanks
1
by: thripurari | last post by:
Hi ! Dear all! I am getting a problem while binding the data source to the ultragrid . pls can any one could help me to bind the excell file to my ultra grid. My Question is: How to bind the...
0
by: =?Utf-8?B?Q2hyaXN0aWFuIEJhaG5zZW4=?= | last post by:
Is it possible to bind a data access page textbox controlsource property at run time? I've tried using the BeforeInitialBind event to set the controlsource for textboxes, using syntax like ...
1
by: littlemaster | last post by:
I am having table in psql it has one field as integer array data type. From rails application I was not able to insert value in that filed. Example: Need to add multiple userid in the name...
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
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...
0
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,...
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
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...
0
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...

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.