Hi,
I am having problem on getting value from dropDown list.
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
OleDbCommand comm;
OleDbConnection conn;
//conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\\Demo11(1).accdb;Persist Security Info=False");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
connectionAndData();
}
}
private void connectionAndData()
{
conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\\Demo11(1).accdb;Persist Security Info=False");
try
{
conn.Open();
Label1.Text = "Connection Esatblished";
if (!IsPostBack)
{
comm = new OleDbCommand("select w2k_id from Employee", conn);
OleDbDataReader rd = comm.ExecuteReader();
while (rd.Read())
{
DropDownList1.Items.Add(rd["w2k_id"].ToString());
}
}
}
catch (Exception exp)
{
Label1.Text = exp.ToString();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label2.Text += DropDownList1.SelectedItem.Value.ToString();
}
}
Problem is, no data is showing when a value is selected from dropdown List in protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e).
Can any one help me,,,,its very urgent...