How do you bind array to gridview? Will it works?

Answers were Sorted based on User's Feedback



How do you bind array to gridview? Will it works?..

Answer / senthilselvan

int[] arr = { 1, 2, 3, 4, 5, 6, 7, 8 };
GridView1.DataSource = arr;
GridView1.DataBind();

try this.

Is This Answer Correct ?    24 Yes 5 No

How do you bind array to gridview? Will it works?..

Answer / uma

all the answers are correct, but its not write way to store
array to grid,if u insert data into grid view as the above
mension answers expect first one answer, the data will be
diaplayed in column wise, actually the data in grid view is
displayed in rowwise, so we convert array data into a
spesfic datasource like lists,generic list etc;


int32[] arr=new int32[10];
arr[1]=2;
arr[2]=3;

list<> lt=new list<arr>
lt.add(arr[1]);
lt.add(arr[2]);
GridView1.DataSource = lt;
GridView1.DataBind();

Is This Answer Correct ?    9 Yes 10 No

How do you bind array to gridview? Will it works?..

Answer / mallu

Dim i As Integer
Dim fib(10) As Integer

fib(0) = 1
fib(1) = 1

For i = 2 To 10
fib(i) = fib(i - 1) + fib(i - 2)
Next

Me.grdResults.DataSource = fib
Me.grdResults.DataBind()

Is This Answer Correct ?    5 Yes 7 No

How do you bind array to gridview? Will it works?..

Answer / alpesh

get the values in to the array

now pull that array values in one Dataset haveing same
array structure

now assign that dataset to the grid view

thats it

Is This Answer Correct ?    7 Yes 10 No

Post New Answer

More ASP.NET Interview Questions

Is there any property names “isnavigating”?

0 Answers  


How to set the pane area to transparent of a scrollPane component.?

0 Answers   MCN Solutions,


What is difference between Fragment Caching and Page Caching in ASP.NET?

0 Answers   PUCIT,


To wrap up a call to a Web service the standard used is..?

0 Answers   Siebel,


When you use Ajax controls in the ASP.NET application?

0 Answers   Viscus Infotech,






What is __ requestverificationtoken?

0 Answers  


What are ASHX files?

0 Answers   HCL,


which scripting is used browser by server when we use validation controls. 1.javascript 2.vbscript 3.jscript 4.perl

8 Answers   Satyam,


Explain what is an abstract class?

0 Answers  


Hi, We have a user control that have button Now we use this user control on different aspx pages. We want when we click on the user control button then button behave differently on different page (Dynamacilly).

2 Answers   HCL,


Explain Authentication mechanism in dotnet

0 Answers   BirlaSoft,


Is overloading possible in web services?

2 Answers   Microsoft,


Categories