Click here to Skip to main content
11,477,834 members (72,597 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET Gridview
Dear frnds,

am working on gridview in c#
SqlConnection con = new SqlConnection(_connString);
SqlDataAdapter da = new SqlDataAdapter("Select * from StudentsInfo",con);
DataSet ds = new DataSet();
Gridview1.datasource = ds.Tables[0];
Please can u explain me this line

Gridview1.Datasource = ds.Tables[0];
what do you mean by ds.tables[0]

Please explain. THANKS.
Posted 1-Jan-13 22:16pm
Edited 1-Jan-13 22:32pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Software Engineer 892 at 2-Jan-13 3:30am
Thanks...I got it.
Abhinav S at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 194
1 Richard Deeming 180
2 OriginalGriff 160
3 Sascha Lefèvre 145
4 Tomas Takac 130
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,256
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,305

Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100