0

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?

1
  • and more tags, to your question like asp.net, or android so that your question can be view by many other users Commented May 8, 2013 at 4:51

2 Answers 2

2

Try

 GridView1.DataBind();

to load the data

Sign up to request clarification or add additional context in comments.

1 Comment

Oh thought you only needed a DataBind if you wanted the GridView permanently linked to the datatable. That worked in so far as the GridView has two rows now, but no columns and hence no data.
0

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();
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.