Loading ...

how to insert item in list box from oracle database

Who is online?  0 guests and 1 members
home  »  forums   »  asp.net topics   »  getting started / general asp.net   » how to insert item in list box from oracle database

how to insert item in list box from oracle database

Posts under the topic: how to insert item in list box from oracle database

Posted: 12/9/2011

Lurker 5  points  Lurker
  • Joined on: 12/9/2011
  • Posts: 1

i am new to asp .net . i have created a table in oracle having 2 columns one is for department name and the other is da name of the students . In the asp.net design page i ahve the drop down list where the name of different departments are given( in my case computer, electronics and electrical). i want a code such that when i click on a particular department say electrical then in the list box i get the name of all the students who belong to electrical department . I am unable to do it. i wrote this code but it isnt working..

 protected void drpdwndept_SelectedIndexChanged(object sender, EventArgs e)
{
Class1 ford = new Class1();

int i,k;
String sql = "select Department,Name from Result";

OracleDataAdapter da = new OracleDataAdapter(sql, ford.ConnectionString);
DataTable dt = new DataTable();
da.Fill(dt);
for(i=0;i<dt.Rows.Count;i++)
{
if(drpdwndept.SelectedItem.Text==dt.Rows[i][0].ToString())
{
k=i;
lstboxstudents.Items.Add (dt.Rows[k][1].ToString());


}
}


Posted: 12/15/2011

Professional 8338  points  Professional
  • Joined on: 4/15/2009
  • Posts: 424
  Answered
Page 1 of 1 (2 items)