ASP.NET error

Hi,

I am trying to change a dropdown list  - so that the user can select multiple options.
I have seen that I should be using a LISTBOX.

When I change the code my page doesn't work.

Original:
  <tr>
            <td><asp:Label ID="lblFieldRep" runat="server" Text="ZF Field Sales Rep" /><em><img src="images/required.gif" alt="Required" /></em></td>
            <td><asp:DropDownList ID="ddlFieldRep" runat="server" AppendDataBoundItems="True" Width="250" CssClass="required" SelectionMode="Multiple"><asp:ListItem Text="Please select..." Value="" /></asp:DropDownList>&nbsp;<img id="imgFieldRep" runat="server" src="images/question.gif" alt="" onmouseout="return nd();" />
               
            </td>
        </tr>

Open in new window


New code:
    <tr>
            <td><asp:Label ID="lblFieldRep" runat="server" Text="ZF Field Sales Rep" /><em><img src="images/required.gif" alt="Required" /></em></td>
            <td><asp:Listbox ID="ddlFieldRep" runat="server" AppendDataBoundItems="True" Width="250" CssClass="required" SelectionMode="Multiple"><asp:ListItem Text="Please select..." Value="" /></asp:Listbox>&nbsp;<img id="imgFieldRep" runat="server" src="images/question.gif" alt="" onmouseout="return nd();" />
               
            </td>
        </tr>
        <tr>

Open in new window



I get an error when I change it.

hh
SmashAndGrabAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
Can you define "doesn't work"?  It would be helpful to get a better understanding of where your code is breaking down.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Reading the error it says you have the field ddlRep defined as DropDownList in the base class but try to use it as a ListBox.  Change it in the base class as well
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SmashAndGrabAuthor Commented:
sorry - the error didn't come through!  I logged that in a rush - apologies.

Heres the error:

error
0
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Kyle AbrahamsSenior .Net DeveloperCommented:
Is the page inheriting from a base class?  If so then you'll need to modify that control to use the listbox However if you have multiple pages that may cause an issue,
0
SmashAndGrabAuthor Commented:
Is there another way I can do it?
0
AndyAinscowFreelance programmer / ConsultantCommented:
>>Is there another way I can do it?

Basically no, if you want to use a ListBox.  You need to change it in the base class.
ps.  If you really do need the ListBox on this page and you have other pages then, maybe, they need a ListBox as well.
0
Kyle AbrahamsSenior .Net DeveloperCommented:
That or use it as another control.  

EG:

ddlFieldRep
and
lbFieldRep

in the base clase.

Then just check if it's null.
0
Obadiah ChristopherCommented:
I think, when you changed the dropdownlist to a listbox in the aspx page, it didn't change in the code-behind.

If that's what is the case, just go to the aspx page and press F7.


-- This is by personal experience only.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Seems to be the problem and how to solve it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.