472,984 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 472,984 software developers and data experts.

datagrid and array

hi guys, my code is returning an array and i need to create datagrid so that
i can have sorting and implement prev....next function on it to navigate. is
there any way this can be done in codebehind file. I am using c#.

Thanks
Manny
Nov 18 '05 #1
4 2068
Manny Chohan wrote:
hi guys, my code is returning an array and i need to create datagrid so that
i can have sorting and implement prev....next function on it to navigate. is
there any way this can be done in codebehind file. I am using c#.


What does your array contain? Just simple, primitive types (int,
string, etc.), or complex classes with properties? If it's the former,
read this article:

Binding a Scalar Array to a Data Web Control
http://aspnet.4guysfromrolla.com/articles/082504-1.aspx

If it's the latter, check out:

Displaying Custom Classes in a DataGrid
http://aspnet.4guysfromrolla.com/articles/102302-1.aspx

Once you have the data bound to the DataGrid, you can use the DataGrid's
sorting, paging, etc. features to implement the sorting and paging and
any other features you need. There's a ton of good DataGrid information
(including info on sorting and paging) in this 16-part articles series:

An Extensive Examination of the DataGrid Web Control
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

Happy Programming!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #2
Hi Scott,

can this be done to datagrid if i need to bind it to array:
DataGrid1.DataSource(allRecords("1").ToString(),al lRecords("2").ToString(),allRecords("3").ToString( ));
Manny Singh

"Scott Mitchell [MVP]" wrote:
Manny Chohan wrote:
hi guys, my code is returning an array and i need to create datagrid so that
i can have sorting and implement prev....next function on it to navigate. is
there any way this can be done in codebehind file. I am using c#.


What does your array contain? Just simple, primitive types (int,
string, etc.), or complex classes with properties? If it's the former,
read this article:

Binding a Scalar Array to a Data Web Control
http://aspnet.4guysfromrolla.com/articles/082504-1.aspx

If it's the latter, check out:

Displaying Custom Classes in a DataGrid
http://aspnet.4guysfromrolla.com/articles/102302-1.aspx

Once you have the data bound to the DataGrid, you can use the DataGrid's
sorting, paging, etc. features to implement the sorting and paging and
any other features you need. There's a ton of good DataGrid information
(including info on sorting and paging) in this 16-part articles series:

An Extensive Examination of the DataGrid Web Control
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

Happy Programming!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!

Nov 18 '05 #3
Your syntax looks a little weird, but, sure, you could create a string
array, populate it with the values, and then bind the string array to
the grid. The code might look like:

ArrayList s = new ArrayList();
s.Add(allRecords("1").ToString());
s.Add(allRecords("2").ToString());
....

DataGrid1.DataSource = s.ToArray(typeof(string));
DataGrid1.DataBind();
That ought to work.
Manny Chohan wrote:
Hi Scott,

can this be done to datagrid if i need to bind it to array:
DataGrid1.DataSource(allRecords("1").ToString(),al lRecords("2").ToString(),allRecords("3").ToString( ));
Manny Singh

"Scott Mitchell [MVP]" wrote:

Manny Chohan wrote:
hi guys, my code is returning an array and i need to create datagrid so that
i can have sorting and implement prev....next function on it to navigate. is
there any way this can be done in codebehind file. I am using c#.


What does your array contain? Just simple, primitive types (int,
string, etc.), or complex classes with properties? If it's the former,
read this article:

Binding a Scalar Array to a Data Web Control
http://aspnet.4guysfromrolla.com/articles/082504-1.aspx

If it's the latter, check out:

Displaying Custom Classes in a DataGrid
http://aspnet.4guysfromrolla.com/articles/102302-1.aspx

Once you have the data bound to the DataGrid, you can use the DataGrid's
sorting, paging, etc. features to implement the sorting and paging and
any other features you need. There's a ton of good DataGrid information
(including info on sorting and paging) in this 16-part articles series:

An Extensive Examination of the DataGrid Web Control
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

Happy Programming!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #4
Sorry Scott, i just found out that the array is a two dimensional array
arrlist[i,z]. Do you have any code that addresses this issue?

Manny

"Scott Mitchell [MVP]" wrote:
Your syntax looks a little weird, but, sure, you could create a string
array, populate it with the values, and then bind the string array to
the grid. The code might look like:

ArrayList s = new ArrayList();
s.Add(allRecords("1").ToString());
s.Add(allRecords("2").ToString());
....

DataGrid1.DataSource = s.ToArray(typeof(string));
DataGrid1.DataBind();
That ought to work.
Manny Chohan wrote:
Hi Scott,

can this be done to datagrid if i need to bind it to array:
DataGrid1.DataSource(allRecords("1").ToString(),al lRecords("2").ToString(),allRecords("3").ToString( ));
Manny Singh

"Scott Mitchell [MVP]" wrote:

Manny Chohan wrote:

hi guys, my code is returning an array and i need to create datagrid so that
i can have sorting and implement prev....next function on it to navigate. is
there any way this can be done in codebehind file. I am using c#.

What does your array contain? Just simple, primitive types (int,
string, etc.), or complex classes with properties? If it's the former,
read this article:

Binding a Scalar Array to a Data Web Control
http://aspnet.4guysfromrolla.com/articles/082504-1.aspx

If it's the latter, check out:

Displaying Custom Classes in a DataGrid
http://aspnet.4guysfromrolla.com/articles/102302-1.aspx

Once you have the data bound to the DataGrid, you can use the DataGrid's
sorting, paging, etc. features to implement the sorting and paging and
any other features you need. There's a ton of good DataGrid information
(including info on sorting and paging) in this 16-part articles series:

An Extensive Examination of the DataGrid Web Control
http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

Happy Programming!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!

Nov 18 '05 #5

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

Similar topics

3
by: serge calderara | last post by:
Dear all, I am using a datagrid which is populate from an array list items This array list can be updated at anytime.If this occurs I need that the content of the datagrid get synchronise too. ...
2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
2
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell...
0
by: Nic | last post by:
Hey, Struggling for a few days now. I have a piece of code (see below). It is an array bound to an asp-datagrid. There are 3 objects in the array, so 3 items in the datagrid. I select the...
3
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
5
by: DKC | last post by:
Hi, Using VB.NET. I have a datagrid having a strongly typed array of objects as its data source. The data from the array of objects is displayed by means of a table style, which is fine, but...
5
by: Dennis | last post by:
I have a class that inherits from DataGrid. I can set the rowheights in a DataGrid by tappig into the "get_Datagridrows" method. However, this does not work for classes that inherit from...
10
by: mark | last post by:
I have a simple windows application that has a function to read a csv file and enter the values into an array A as double(,). Also, an instance of form 2 (which has a DataGrid) is created and the...
5
by: rn5a | last post by:
In my application, I want to populate all the directories & files existing in a directory on the server in a DataGrid. To ensure that all the directories get listed first followed by all the files,...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.