0

I'm developing a SharePoint solution, In an Application Page, I want to place SPGridView and I have to bind it with SQL server data.

Is it possible and if yes, how?

1

Yes it is possible, here is a basic example:

protected void Page_Load(object sender, EventArgs e)
{
    const string ConnectionString = @"Persist Security Info=False; Integrated Security=SSPI; Server=hercules\sqlexpress;Connect Timeout=30;Database=TestDB;";
    SqlConnection con = new SqlConnection(ConnectionString);
    SqlCommand cmd = new SqlCommand("select * from CustomerTable", con);
    SqlDataAdapter adp = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    adp.Fill(ds);

   DataTable dt = ds.Tables[0];
    gridview1.DataSource = dt.DefaultView;
    gridview1.DataBind();
 }

from here

-1

yes we can bind data to spgridview same as gridview.

  • Can you please add more details to this answer about how that is done? Your answer is not as helpful as it could be right now :) – Robert Lindgren Mar 25 '15 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.