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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
rahul pawarPosted Jan 21, 2008, 12:25 AM
//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();
Gautam SharmaPosted Jan 14, 2008, 9:45 AM
if(ds.Rows.Count >0)
{
GridView1.DataSource = ds;
}
else
{
GridView1.DataSource = null;
}
GridView1.Databind();
Gautam SharmaPosted Jan 14, 2008, 9:44 AM
if(ds.Rows.Count >0)
{
GridView1.DataSource = ds;
}
else
{
GridView1.DataSource = null;
}
GridView1.Databind();
Raj KumarPosted Jan 1, 2008, 7:35 AM
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
Kumar DuvvarapuPosted Dec 27, 2007, 12:46 AM
Hi,
u can bind the table to gridview
gridview.DataSource = dt;
gridview.Databind();