0

I have written the following lines of code to retrieve data from database. When I checked through a lable it is showing that the datatable has data, but its unable to display the data in gridview. Can anyone suggest any solution to this.Thanks in advance

    DataSetTableAdapters.retrievebookingTableAdapter rta = new dataSetTableAdapters.retrievebookingTableAdapter();
    DataSet.retrievebookingDataTable rdt;
    rdt = rta.GetData(EmailID.Text);
    GridView1.DataSource = rdt;
    GridView1.DataBind();
    if (rdt == null)
    {
        Label1.Visible = true;
        Label1.Text = "No data found";
    }
    else
    {
        Label1.Visible = true;
        Label1.Text = "data exists";
    }
Saikat
  • 41
  • 5
  • Use `Tables` property of your `DataSet` like this `GridView1.DataSource = rdt.Tables[0]` check this https://stackoverflow.com/a/35796414/2946329 – Salah Akbari Jul 03 '18 at 09:55
  • __Do not__ call a `DataGridView`a `GridView` or a `DataGrid` and vice versa!! This is wrong and confusing as those are different controls. Always call things by their __right__ name! - Also testing only for null is maybe not good enough.. – TaW Jul 03 '18 at 10:02

0 Answers0