views:

32

answers:

1

I have added a "tooltip" to my dropdownlist using the following codebehind:

        protected void btnAdd_Click(object sender, EventArgs e)
    {
        load_Buttons(1);
        tblAddCandidate.Visible = true;
        txtAdd_RegDate.Text = DateTime.Today.ToShortDateString();


        foreach (ListItem _listItem in this.ddlAssTutAdd.Items)
        {
            _listItem.Attributes.Add("title", _listItem.Text);
        }


        ddlAssTutAdd.Attributes.Add("onmouseover", "this.title=this.options[this.selectedIndex].title");

        ddlAssTutAdd.SelectedIndex = -1; ddlCentresAdd.SelectedIndex = -1; rblAdd_Gender.SelectedIndex = -1;
        txtAdd_CandNo.Text = ""; txtAdd_DOB.Text = ""; txtAdd_Ethnicity.Text = ""; txtAdd_Forename.Text = "";
        txtAdd_Initials.Text = ""; txtAdd_LRS.Text = ""; txtAdd_Notes.Text = ""; txtAdd_RegDate.Text = "";
        txtAdd_Surname.Text = "";

        txtAdd_CandNo.Focus();

    }

(aspx code below)

                                    <asp:DropDownList ID="ddlAssTutAdd" TabIndex="9" runat="server" DataSourceID="SqlDataSource_TutAss"
                                    DataTextField="StaffName" DataValueField="StaffID" Width="300px"
                                    AppendDataBoundItems="true" >
                                    <asp:ListItem Value="0" Text="Please Select..." />    
                                </asp:DropDownList>

                                <asp:SqlDataSource ID="SqlDataSource_TutAss" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:CenCoordConStr %>" 
                                    SelectCommand="SELECT Staff.StaffID + ' : ' + Staff.StaffFirstname + ' ' + Staff.StaffSurname AS StaffName, Staff.StaffID FROM Staff INNER JOIN Assessors ON Staff.StaffID = Assessors.StaffID">
                                </asp:SqlDataSource>

However it only works once you click the "Add" button for the second time. Clicking it once loads the tooltip with "Please Select..." but it shows this tooltip when hovering over any item in the dropdown list. Once you select an item, the tooltip no longer functions. If you click the "Add" button again it all works correctly!

Does anybody have an idea?

Thanks, Nathan

A: 

Sorry Lee Sy En, I should have said that I am using IE8.

I got around the problem by setting the datasource in the codebehind rather than in the aspx code. I'd still like to know why it didn't work this way though if anyone can shed some light on it, just out of curiosity!

Nathan