string conString = ConfigurationManager.ConnectionStrings["tempdbConnectionString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
using (SqlConnection con = new SqlConnection(conString))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT [Teacher_ID], [Teacher_Name] FROM [Student_Master]; SELECT [Student_ID] ,[Teacher_ID],[Student_Name],[Passed] FROM [dbo].[Student_Details]", con))
{
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
DataSet ds = new DataSet();
da.Fill(ds);
ddlTeacher.DataSource = ds.Tables[0];
ddlTeacher.DataBind();
ddlTeacher.Items.Insert(0, new ListItem("-Select-", "0"));
grdStudentDetails.DataSource = ds.Tables[1];
grdStudentDetails.DataBind();
}
}
con.Close();
}
}
}
No comments:
Post a Comment