WAP to display data in ASP.Net GridView Control from SQL Database using ADO.Net disconnected Architecture.
Explanation:- Please check the explanation of ADO.Net connected Architecture program.WebForm1.aspx.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
namespace ADO.net_Tutorial
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//bind gridviw using disconnted architechture of ado.net
string constr = ConfigurationManager.ConnectionStrings["testconstr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand(" select * from EmployeeDetails", con);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}
No comments:
Post a Comment