Click here to Skip to main content
15,890,512 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: C#.Net Windows Application Pin
Mohsin Afzal27-May-13 3:47
professionalMohsin Afzal27-May-13 3:47 
AnswerRe: C#.Net Windows Application Pin
MaulikDusara26-May-13 18:30
MaulikDusara26-May-13 18:30 
GeneralRe: C#.Net Windows Application Pin
Mohsin Afzal27-May-13 3:45
professionalMohsin Afzal27-May-13 3:45 
Questionmvc book Pin
Member 870181318-May-13 1:13
Member 870181318-May-13 1:13 
AnswerRe: mvc book Pin
cyber_addicted21-May-13 0:38
cyber_addicted21-May-13 0:38 
GeneralRe: mvc book Pin
Member 870181321-May-13 3:40
Member 870181321-May-13 3:40 
GeneralRe: mvc book Pin
cyber_addicted21-May-13 20:15
cyber_addicted21-May-13 20:15 
QuestionAccess Database, ASP/C# Drop Down List populating a Drop Down List Pin
WickedFooker17-May-13 15:00
WickedFooker17-May-13 15:00 
Ok this has sort of been asked before but also somewhat differently here. I have a regular drop down (not connected to a database) that just has the topics of subjects.

This is a sample of what I have:

C#
<asp:DropDownList id="ddlcourseType" runat="server" 
                            onselectedindexchanged="ddlcourseType_SelectedIndexChanged" 
                            AutoPostBack="True">
                       <asp:ListItem Value="None">Please Select</asp:ListItem>
                       <asp:ListItem Value="Engl">English</asp:ListItem>
                       <asp:ListItem Value="Math">Math</asp:ListItem>
                       <asp:ListItem Value="Soci">Social Studies</asp:ListItem>
                       <asp:ListItem Value="Scie">Science</asp:ListItem>
                       <asp:ListItem Value="Hist">History</asp:ListItem>
                       </asp:DropDownList>


I want to make it so that when it changes the next part will search and select teachers that teach that specific subject. I am using an Access Database for connection.

I have pieced together some of what others did in an attempt to get it to work but no.

C#
protected void ddlcourseType_SelectedIndexChanged(object sender, EventArgs e)
   {
       OleDbConnection dbConn = null;
       OleDbCommand dbCmd;
       OleDbDataReader dr;
       String strConnection;
       String strSQL;
       string path = Server.MapPath("eAcademy_DB.mdb");

       string Teachable = Convert.ToString(ddlcourseType.SelectedValue);
       strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
       dbConn = new OleDbConnection(strConnection);
       dbConn.Open();
       strSQL = "select * from tblEmployee where canTeach=" + Teachable;

       dbCmd = new OleDbCommand(strSQL, dbConn);
       DataSet ds = new DataSet();

       dbConn.Close();
       ddlTeacher.DataSource = ds;
       ddlTeacher.DataTextField = "emp_ID";
       ddlTeacher.DataValueField = "emp_ID";
       ddlTeacher.DataBind();
       ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
       if (ddlTeacher.SelectedValue == "0")
       {
           ddlTeacher.Items.Clear();
           ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
       }
   }


I think what I really need to do is make a for loop and have it iterate for the amount of teachers that are in the list, and then have it populate the list, but not sure how exactly to do this.

It is hanging up on the ds part each time. I know the databind is causing it so this is why I thought perhaps better to iterate this? Any help would be appreciated.

The values from the first list are in the tblEmployee for "T" Teachers that can teach those classes. So that is why I want to 2nd drop down populated with their names. Thanks!
AnswerRe: Access Database, ASP/C# Drop Down List populating a Drop Down List Pin
Richard Deeming20-May-13 2:02
mveRichard Deeming20-May-13 2:02 
GeneralRe: Access Database, ASP/C# Drop Down List populating a Drop Down List Pin
WickedFooker20-May-13 5:34
WickedFooker20-May-13 5:34 
AnswerRe: Access Database, ASP/C# Drop Down List populating a Drop Down List Pin
cyber_addicted21-May-13 0:53
cyber_addicted21-May-13 0:53 
Questionhow to write sql's not in operator using linq to entities 4.0 Pin
indian14317-May-13 7:14
indian14317-May-13 7:14 
AnswerRe: how to write sql's not in operator using linq to entities 4.0 Pin
R. Giskard Reventlov20-May-13 6:11
R. Giskard Reventlov20-May-13 6:11 
QuestionEF:How to link Expressions in order to generate an OR/AND Linq query Pin
Clodetta del Mar17-May-13 1:44
Clodetta del Mar17-May-13 1:44 
Answer[solved?]the concrete calling...the priority problem Pin
Clodetta del Mar17-May-13 2:51
Clodetta del Mar17-May-13 2:51 
QuestionHow to use different fonts? Pin
Jassim Rahma16-May-13 10:15
Jassim Rahma16-May-13 10:15 
AnswerRe: How to use different fonts? Pin
Richard MacCutchan16-May-13 21:20
mveRichard MacCutchan16-May-13 21:20 
AnswerRe: How to use different fonts? Pin
Jitendra Parida - Jeetu20-May-13 1:02
Jitendra Parida - Jeetu20-May-13 1:02 
AnswerRe: How to use different fonts? Pin
wikizhao27-May-13 21:18
wikizhao27-May-13 21:18 
QuestionHow to Open Datalist Link Button in New Tab in browser Pin
Member 998801815-May-13 21:35
Member 998801815-May-13 21:35 
AnswerRe: How to Open Datalist Link Button in New Tab in browser Pin
Richard Deeming16-May-13 1:32
mveRichard Deeming16-May-13 1:32 
Questionc# code to download .xlsm file Pin
Sachin Adsul15-May-13 21:20
Sachin Adsul15-May-13 21:20 
AnswerRe: c# code to download .xlsm file Pin
ZurdoDev21-May-13 10:26
professionalZurdoDev21-May-13 10:26 
QuestionPlease Help With Various Methods of Optical Character Recognition which can be used for successful Conversion?? Pin
Kaushal Behere15-May-13 20:52
professionalKaushal Behere15-May-13 20:52 
QuestionHtml to PDF Pin
Denzil_Sdn15-May-13 19:56
Denzil_Sdn15-May-13 19:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.