Results 1 to 9 of 9

Thread: [RESOLVED] Select one combox box item another combo box is triggered

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Resolved [RESOLVED] Select one combox box item another combo box is triggered

    Hi,

    I am working with Vb.Net and have 2 combo boxes..

    cmbchngcrt and cmbmgrname..

    Both combo boxes are data binded and have a dropdownlist with the list read from SQL DB.

    Now, when I select a value "website" from cmbchngcrt, I want to do 2 things;

    1) select the value "Ready for Update" from cmbmgrname dropdownlist. Then
    2) Disable cmbmgrname

    How can I achieve this please..

    Thanks

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,758

    Re: Select one combox box item another combo box is triggered

    Put the following code in the cmbchgcrt.selectedItem_changed event handler....

    Code:
    If cmbchngcrt.selecteditems = "website" then
        cmbmgrname.selecteditem = "Ready for Update"
        cmbmgrname.enabled = false
    endif
    you should probably add something to the code for when the selection is not website to maybe enable the combobox.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Re: Select one combox box item another combo box is triggered

    First, I dont have cmbchgtyp.selecteditem_changed event handler instead I have cmbchgtyp_selectedindexchanged.

    Secondly,

    added in the selectedindexchanged event handler

    Code:
    If cmbchngcrt.selecteditems = "website" then
        cmbmgrname.selecteditem = "Ready for Update"
        cmbchngcrt.enabled = false
    endif
    the first two lines are underlined in Blue - denoting errors..

    Any help pls

  4. #4
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,758

    Re: Select one combox box item another combo box is triggered

    First, I dont have cmbchgcrt.selecteditem_changed event handler instead I have cmbchgtyp_selectedindexchanged.
    If you want stuff to happen when the value in cmbchngcrt changes then you need to put the code in the cmbchngcrt change handler. Either the selectedIndex_Changed or selectedItem_Changed would work.



    the first two lines are underlined in Blue - denoting errors..

    Any help pls
    It kind of depends on the errors. I have a good idea about what they might be. What are the errors?
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Re: Select one combox box item another combo box is triggered

    Error 1:
    Property 'SeletectedItem' is 'ReadOnly'

    Error 2:
    Value of type 'System.Web.UI.WebControls.ListItem' cannot be converted to 'String'


    Thanks

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Re: Select one combox box item another combo box is triggered

    any help please

  7. #7
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,758

    Re: Select one combox box item another combo box is triggered

    First, the code I gave you has a syntax error.... it should be

    Code:
    If cmbchngcrt.selecteditem = "website" then
        cmbmgrname.selecteditem = "Ready for Update"
        cmbchngcrt.enabled = false
    endif
    not
    Code:
    If cmbchngcrt.selecteditemS = "website" then
        cmbmgrname.selecteditem = "Ready for Update"
        cmbchngcrt.enabled = false
    endif
    but that has nothing to do with your errors which are not the errors I thought you were having.

    Second,
    The first line of the MSDN Remarks section of the comboBox states

    When you set the SelectedItem property to an object...
    That says that the SelectedItem property of the comboBox is not ReadOnly but can also be written to. Are you sure you are using a combobox?

    Third,
    Why are you getting an error related to a System.Web.UI.WebControls.ListItem? You have not mentioned anything about a web control. Is that what you are using?
    Last edited by kebo; Sep 16th, 2014 at 11:14 PM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Re: Select one combox box item another combo box is triggered

    Hey,

    This is what I have on the asp page for the combo box --

    Code:
     <asp:DropDownList ID="cmbchngtyp" runat="server" CssClass="combo" DataSourceID="ChangeTypeDataSource"
                                            DataTextField="TypeDesc" DataValueField="TypeDesc" AppendDataBoundItems="True">
                                            <asp:ListItem Value="-1">Please Select</asp:ListItem>
                                        </asp:DropDownList>
                                        <asp:SqlDataSource ID="ChangeTypeDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CCMSConnectionString %>"
                                            SelectCommand="SELECT [TypeDesc] FROM [TblChangeType] ORDER BY [TypeDesc]"></asp:SqlDataSource>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" InitialValue="-1" ErrorMessage="RequiredFieldValidator"
                                            ControlToValidate="cmbchngtyp" Text="Change Type is required" CssClass="fieldmax"></asp:RequiredFieldValidator>
    <asp:Label ID="Label51" runat="server" Text="test1"></asp:Label>
    So, on the vb page as a test I wanted to check if I change the cmbchngtyp - Label51 should display the text = This is a Text

    Code:
    Protected Sub cmbchngtyp_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbchngtyp.SelectedIndexChanged
    
    		Label51.Text = "This is a TEST"
    
    	End Sub
    This is not working and at runtime if I change the cmbchngtyp value the text DOES NOT change..

    Any help please

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Re: Select one combox box item another combo box is triggered

    Ok - AutoPostBack = TRUE was required now I can change the text of the label if the cmbchngTyp selected item is changed.

    All working thanks
    Last edited by dr223; Sep 17th, 2014 at 05:32 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width