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

Can we change the session timeout in ASP.NET, if yes then how and from where?

7 Answers   L&T,


When we are requesting a new URL through Response.Redirect() the new page wil open on the new browser window or it wil open in the same window? If we use Server.Transfer() what wil happen?

1 Answers  


can s/w quality assurance engineer switch field to programming side i m very much interested in programming but not much good in it

0 Answers  


What is the use of dispose method?

0 Answers  


If(dropdownlist1.selectedIndexChanged==true) { //code } else { //code } I am getting error in If condition, so can u pls give me a solution.

4 Answers  






How can we prepairing Interview

0 Answers   ITcom, TCS,


Difference between HTML control and Web Server Control?

4 Answers  


Who can consume WebAPI?

0 Answers  


Which is faster union or union all?

0 Answers  


Define managed code and managed data in .net?

0 Answers  


What is an il?

0 Answers  


how to debug web services on consumer side?

0 Answers   HCL,


Categories