473,394 Members | 1,189 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,394 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 1368
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.