Learn when you want, where you want with convenient online training courses. Sign up now!
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
public partial class WebForm1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
string cs = ConfigurationManager.ConnectionStrings["StudentDB"].ConnectionString;
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("Select ID, FirstName, LastName, Gender FROM Students WHERE Gender='Male'");
List<Student> listStudents = new List<Student>();
SqlDataReader rdr = cmd.ExecuteReader();
Student student = new Student();
student.ID = Convert.ToInt32(rdr["ID"]);
student.FirstName = rdr["FirstName"].ToString();
student.LastName = rdr["LastName"].ToString();
student.Gender = rdr["Gender"].ToString();
GridView1.DataSource = listStudents;
For more information on how to configure your ASP.NET application, please visit
Data Source=USER-PC;Initial Catalog=ROD_July18;Integrated Security=True
Data Source=.\SQLEXPRESS12;Initial Catalog=MME_Sample; Integrated Security=True
<add name="StudentDB" connectionString="Data Source=.\SQLEXPRESS12;Initial Catalog=MME_Sample; Integrated Security=True" providerName="System.Data.SqlClient"/>
<compilation debug="true" targetFramework="4.5"/>
Open in new window
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.