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?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityYes 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
yes we can bind data to spgridview same as gridview.