Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear frnds,

am working on gridview in asp.net c#
C#
{
SqlConnection con = new SqlConnection(_connString);
SqlDataAdapter da = new SqlDataAdapter("Select * from StudentsInfo",con);
DataSet ds = new DataSet();
da.fill(ds);
Gridview1.datasource = ds.Tables[0];
} 

Please can u explain me this line

C#
Gridview1.Datasource = ds.Tables[0];

what do you mean by ds.tables[0]

Please explain. THANKS.
Posted
Updated 1-Jan-13 21:32pm
v2

What does who mean ? Is this a response to an answer, or an article ?

You should consider reading some basic books on C#, because it's clear you don't really understand it well enough to be working in it. ds is a DataSet, as you can see. It has a Tables property. It is an array. The first table in the array has an index of 0. ds.Tables[0] returns the first table in the dataset.
 
Share this answer
 
Get familiar with the concept of a Dataset.
Essentially, a dataset is a collection of datatable objects (each of which could correspond to a table in the database).

When you say ds.tables[0], you are accessing the first table in the dataset.
You are then assigning it to the datasource of the GridView.
 
Share this answer
 
Comments
Software Engineer 892 2-Jan-13 3:30am    
Thanks...I got it.
Abhinav S 2-Jan-13 3:39am    
You are welcome. Vote if it helped.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900