File 1: Default2.aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<p></p>
<p></p>
<form id="form1" runat="server" action="login_by_trainees_for_oe1.aspx">
<table align="center" cellpadding="20" style="margin:100px;background-color:#f0f0f0">
<tr>
<td colspan="2" align="center" style="font:bold
24px arial">
Online Examination Login
<hr />
</td>
</tr>
<tr>
<td>
Select Your Institute
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server"
DataTextField="EmpName" DataValueField="EmpId">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Next..." style="font:bold
24px arial" />
</td></tr>
</table>
</form>
</body>
</html>
======================================================
Default2.aspx.cs code:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
//the above line is must for oracleconnection,cmd,dr
using System.Data;
//the above line is must for datatable
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// String oradb = "Data Source=xe;User Id=scott;Password=tiger;";
String oradb = System.Configuration.ConfigurationSettings.AppSettings["openMyConn"];
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
string sql = "select * from master_staff";
OracleCommand cmd = new OracleCommand(sql, conn);
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
DataTable dt = new DataTable();
dt.Load(dr);
DropDownList1.DataSource = dt;
DropDownList1.DataBind();
// label1.Text = dr["EmpName"].ToString();
}
}
web.config file
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true">
<assemblies>
<add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
</system.web>
<appSettings>
<add key="openMyConn" value="Data Source=xe;User Id=scott;Password=tiger;"/>
</appSettings>
</configuration>