www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: pls help me work on asp.net

  1. #1
    Join Date
    Oct 2006
    Posts
    25

    Wink pls help me work on asp.net

    Hi,

    I am working in visual web developer and asp.net. as i am new to this program. pls help me out.

    well, i tried to get my item on dropDownList1(College Name) and as i select one item from list1, corresponding list(Department) should be provided on dropDownList2. I got the item on first list, but could no manipulate it to get on the other. Pls tell me a way to do so. Its really urgent for me. please.

  2. #2
    Join Date
    Oct 2006
    Posts
    36
    Hi.....

    Use "DropDownList1_SelectedIndexChanged" event to fill the departments in DropDownList2.Under this event follow the coding as needed.

    Also set "AutoPostBack" property "True" for DropDownList1
    Last edited by Chitra Xavier; 10-25-2006 at 02:17 AM.
    Njoi Coding
    Chitra Xavier Ray
    .Net Developer

  3. #3
    Join Date
    Oct 2006
    Posts
    25

    My code

    well, my first ddlist is dlCollege and second one is DlDept. so, i wrote the following code. but nothigns happend.


    Protected Sub DlCollege_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DlCollege.SelectedIndexChanged

    If DlCollege.Items.Item(0).Equals("Agriculture and Biological Sciences".ToString()) Then
    DlDept.Items.Add("Ag Infor Tech Unit".ToString())
    DlDept.Items.Add("Computer Unit".ToString())
    DlDept.Items.Add("Research Lab".ToString())
    DlDept.Items.Add("Agriculture purification".ToString())
    DlDept.Items.Add("Main post info".ToString())

    ElseIf DlCollege.Items.Item(1).Equals("Arts and Science".ToString()) Then
    DlDept.Items.Add("Arts Tech Unit".ToString())
    DlDept.Items.Add("Technical Department".ToString())




    End If
    End Sub

  4. #4
    Join Date
    Oct 2006
    Posts
    36
    Hi....

    Instead of using "Equals()" use Equality operator.
    Also dont forget to give "AutoPostBack" property "True" for DlCollege

    If DlCollege.SelectedItem.ToString() = "Agriculture and Biological Sciences".ToString() Then
    DlDept.Items.Add("Ag Infor Tech Unit".ToString())
    DlDept.Items.Add("Computer Unit".ToString())
    DlDept.Items.Add("Research Lab".ToString())
    DlDept.Items.Add("Agriculture purification".ToString())
    DlDept.Items.Add("Main post info".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Arts and Science".ToString() Then
    DlDept.Items.Add("Arts Tech Unit".ToString())
    DlDept.Items.Add("Technical Department".ToString())
    Last edited by Chitra Xavier; 10-25-2006 at 02:17 AM.
    Njoi Coding
    Chitra Xavier Ray
    .Net Developer

  5. #5
    Join Date
    Oct 2006
    Posts
    25
    hi.. Chitra.

    thanks for your suggestion. i hope you dont mind that i am quite novice in asp.net and stuffs. well, please tell me one thing. you know, i am using right now microsoft visual web developer to work with asp.net. and i have come to knwo that lots of ppl use visual studio.net 2003. so, please tell me what is the difference among these two.

    could you?? sorry if i disturbed in between.

  6. #6
    Join Date
    Oct 2006
    Posts
    36
    I havent worked with Visual Web Developer.To the extent i know about is,good for beginners.Mainly meant for easy developing of web sites
    Njoi Coding
    Chitra Xavier Ray
    .Net Developer

  7. #7
    Join Date
    Oct 2006
    Posts
    25
    hi chitra,,

    wow, thanks for the suggestion. but well, it did not work fully again. the problem is that, when the page loads, first item in the first listbox is already selected, corresponding list does not show in the second list box.
    Also, once, when second item in the first listbox is already selected, corresponding list show up in the second listbox, but when i select third item in the first list box, the second listbox does not get changed.!! My code is as follows: but then when i select one item in list1, items on list 2 keeps on adding over the previous one instead of displaying the new list for corresponding selection in list1.
    While i add the items, is there some indexing i got to give for first list box??

    If DlCollege.SelectedItem.ToString() = "Agriculture and Biological Sciences".ToString() Then
    DlDept.Items.Add("Ag Infor Tech Unit".ToString())
    DlDept.Items.Add("AgBio Communications Unit".ToString())


    ElseIf DlCollege.SelectedItem.ToString() = "Arts and Science".ToString() Then
    DlDept.Items.Add("AROTC".ToString())
    DlDept.Items.Add("AFROTC".ToString())


    ElseIf DlCollege.SelectedItem.ToString() = "Education and Counseling".ToString() Then
    DlDept.Items.Add("Educational Leadership".ToString())
    DlDept.Items.Add("CHRD".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Engineering".ToString() Then
    DlDept.Items.Add("Civil & Environmental Engr.".ToString())
    DlDept.Items.Add("Mechnical Engineering".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Family and Consumer Sciences".ToString() Then
    DlDept.Items.Add("AMID".ToString())
    DlDept.Items.Add("HDCFS".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "General Studies and Outreach Programs".ToString() Then
    DlDept.Items.Add("".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Nursing".ToString() Then
    DlDept.Items.Add("Graduate Nursing".ToString())
    DlDept.Items.Add("Nursing Student Services".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Pharmacy".ToString() Then
    DlDept.Items.Add("Pharmacy Practice".ToString())
    DlDept.Items.Add("Pharmaceutical Sciences".ToString())

    End If
    End Sub



    Please help me solve it!!
    Last edited by ddl; 10-25-2006 at 10:14 AM. Reason: Please review my code!!

  8. #8
    Join Date
    Oct 2006
    Posts
    36
    Hi ddl..

    Kindly follow the code below.Sure u will get it.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Call DropDown()
    End Sub

    Private Sub DlCollege_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DlCollege.SelectedIndexChanged
    Call DropDown()
    End Sub


    Public Sub DropDown()

    DlDept.Items.Clear()
    If DlCollege.SelectedItem.ToString() = "Agriculture and Biological Sciences".ToString() Then
    DlDept.Items.Add("Ag Infor Tech Unit".ToString())
    DlDept.Items.Add("AgBio Communications Unit".ToString())


    ElseIf DlCollege.SelectedItem.ToString() = "Arts and Science".ToString() Then
    DlDept.Items.Add("AROTC".ToString())
    DlDept.Items.Add("AFROTC".ToString())


    ElseIf DlCollege.SelectedItem.ToString() = "Education and Counseling".ToString() Then
    DlDept.Items.Add("Educational Leadership".ToString())
    DlDept.Items.Add("CHRD".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Engineering".ToString() Then
    DlDept.Items.Add("Civil & Environmental Engr.".ToString())
    DlDept.Items.Add("Mechnical Engineering".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Family and Consumer Sciences".ToString() Then
    DlDept.Items.Add("AMID".ToString())
    DlDept.Items.Add("HDCFS".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "General Studies and Outreach Programs".ToString() Then
    DlDept.Items.Add("".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Nursing".ToString() Then
    DlDept.Items.Add("Graduate Nursing".ToString())
    DlDept.Items.Add("Nursing Student Services".ToString())

    ElseIf DlCollege.SelectedItem.ToString() = "Pharmacy".ToString() Then
    DlDept.Items.Add("Pharmacy Practice".ToString())
    DlDept.Items.Add("Pharmaceutical Sciences".ToString())

    End If
    End Sub
    Last edited by Chitra Xavier; 10-26-2006 at 12:22 AM.
    Njoi Coding
    Chitra Xavier Ray
    .Net Developer

  9. #9
    Join Date
    Oct 2006
    Posts
    25
    Hi chitra,

    Thank you so much..you've really been of great help. Thanks again. wow, i am happy that i can also work with asp!!hey man. got lot more to ask to you. dont feel bad bt it ha.

    Thanks man!

    well, on your given suggestion, i got the list of items on the second list according to selection on the first one. but the problem is that, if i select a new item from second list, the item being displayed on it does not get replaced.

    Actually, now if i select any departments, then automatically respective department head's name and dept email address should pop in the two following ddlist boxes, namely dlDeptHead and dlDeptEmail.

    well, i coded as below, but now it says, a debugging error as follows:

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.


    Protected Sub DlDept_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DlDept.SelectedIndexChanged

    DlDept.Items.Clear()
    Call DropDownDlDeptHead()

    End Sub



    Public Sub DropDownDlDeptHead()

    DlDeptHead.Items.Clear()

    If DlDept.SelectedItem.ToString() = "Ag Infor Tech Unit".ToString() Then
    DlDeptHead.Items.Add("Dr. Thomas Gerudn".ToString())
    DlDeptEmail.Items.Add("thomas.gerudn@hotmail.com".ToString())
    ElseIf DlDept.SelectedItem.ToString() = "AgBio Communications Unit".ToString() Then
    DlDeptHead.Items.Add("Ms. Barb Hartinger".ToString())

    End If
    End Sub


    Thank you...
    Hope to hear from you soon

    Does that relate something to the database??
    Last edited by ddl; 10-26-2006 at 08:33 PM.

  10. #10
    Join Date
    Oct 2006
    Posts
    36
    Hi ddl..

    To avoid error give "AutoPostBack" property "True" for all the DropDowns u use.

    Its always safe to use database,since the program we do should be adaptive for future changes.Hard coding limits the usage of a program.Always code generic.
    Njoi Coding
    Chitra Xavier Ray
    .Net Developer

  11. #11
    Join Date
    Oct 2006
    Posts
    25

    hey, say if this "if statement" is false!!

    '''
    Last edited by ddl; 10-29-2006 at 04:12 PM.

  12. #12
    Join Date
    Oct 2006
    Posts
    25

    hey, say if this "if statement" is false!!

    If DlList1.SelectedItem.ToString() = "Ag Infor Tech Unit".ToString() Then


    (fist line---) DlList2.Items.Add("Dr. Mike Adelaine".ToString())

    (second line--- ) DlList3l.Text.Insert"tprerana@hotmail.com".ToString())


    End If



    what i tried to do is, when i have item selected in DlList1, DlList 2 and DlList3 should be filled in with respective values. but, the way i am doin is not correct. it works when i only gice DlList2. but when i add the second line after first line, the if statement seems not to work.

    please tell me a way to solve it.



    Thanks in advance!!

  13. #13
    Join Date
    Oct 2006
    Posts
    36
    Hi,

    If DlList3 is DropDownList control then "Text.Insert" is not an property of dropdown.
    Also check the Id value of DlList3 with the given above code.I think they differ.
    Njoi Coding
    Chitra Xavier Ray
    .Net Developer

  14. #14
    Join Date
    Oct 2006
    Posts
    36
    Hi,
    DlList3l.Text.Insert("tprerana@hotmail.com".ToString())

    U have missed the open braces
    Njoi Coding
    Chitra Xavier Ray
    .Net Developer

  15. #15
    Join Date
    Oct 2006
    Posts
    25
    oh hi chitra,,

    thanks..
    it worked!!
    ya, that was my mistake. it did work this way!!

    If DlDept.SelectedItem.ToString() = "Ag Infor Tech Unit".ToString() Then
    dlDeptHead.Items.Add("Dr. Mike Adelaine".ToString())
    DlDeptEmail.Text = "Michael.Adelaine@SDSTATE.EDU".ToString()

    well, chitra, right now, as i was working, all of a sudden, an error poped in saying:

    Failed to generate a user instance of SQL Server due to a failure in starting the process for the uer instance. The connection will be closed.

    could you please tell me what is it?

    Thanks,..

    hope i am not goin to give you a burden to send the entire project over mail and tell,, hey chitra, could you pls see............and then....i am done with my final project!!

    jj..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles