0
votes

I'm trying to display some data from a Stored Procedure into my GridView. What I'm doing is onLoad; creating a DataTable, adding two rows to it (debugged and there's definitely data in them) and then;

GridView1.DataSource = DataTable

However my GridView comes back empty every time. Why is this?

2
and more tags, to your question like asp.net, or android so that your question can be view by many other users - Qadir Hussain

2 Answers

2
votes

Try

 GridView1.DataBind();

to load the data

0
votes

On The page load we can bind the data with data table

protected void Page_Load(object sender, EventArgs e)
{

    con.Open();
    cmd = con.CreateCommand();

    string CommandText1 = "select * from TRAVEL_Preferences_INFO where USER_ID='" + str_USER_ID + "'";
    DB = new SQLiteDataAdapter(CommandText1, con);
    DS.Reset();
    DB.Fill(DS);
    DT = DS.Tables[0];
    grdTravelPreference.DataSource = DT;
    grdTravelPreference.DataBind();
}