Hi i am new to .net,
I need to knoe how to display the entire table data in grid view using c#..
Hi i am new to .net,
I need to knoe how to display the entire table data in grid view using c#..
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kumar Duvvarapu37 reputationPosted Dec 26, 2007, 7:46 PM EST
Hi,
u can bind the table to gridview
gridview.DataSource = dt;
gridview.Databind();
Raj KumarRank #25 · 44.2K reputationPosted Jan 1, 2008, 2:35 AM EST
Dim dataTable As New DataTable
dataTable = GetRecords() ' function
If (dataTable.Rows.Count > 0) Then
GridView.DataSource = dataTable.DefaultView
GridView.DataBind()
Else
ErrorLabel.Visible = True
ErrorLabel.Text = "No records found"
.DataSource = Nothing
End If
Gautam Sharma36 reputationPosted Jan 14, 2008, 4:44 AM EST
if(ds.Rows.Count >0)
{
GridView1.DataSource = ds;
}
else
{
GridView1.DataSource = null;
}
GridView1.Databind();
Gautam Sharma36 reputationPosted Jan 14, 2008, 4:45 AM EST
if(ds.Rows.Count >0)
{
GridView1.DataSource = ds;
}
else
{
GridView1.DataSource = null;
}
GridView1.Databind();
rahul pawar14 reputationPosted Jan 20, 2008, 7:25 PM EST
//First make the connection
SqlConnection ObjConnection = new SqlConnection(" Connection string");
SqlDataAdapter ObjDataAdapter= new SqlDataAdapter("Select * from Table Name",ObjConnection); //Give the table name from where you want to fetch data
DatSet ObjDataSet= new ObjDataSet();
ObjDataAdapter.Fill(ObjDataset,"Dataset table Name"); //Store data into dataset table by any Name
GridView1.DataSource=ObjDataSet.Tables["DataSet Table Name"];
GridView1.Databind();