• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 49
  • Last Modified:

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
0
SmashAndGrab
Asked:
SmashAndGrab
  • 3
  • 3
  • 2
  • +1
2 Solutions
 
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
 
SmashAndGrabAuthor Commented:
sorry - the error didn't come through!  I logged that in a rush - apologies.

Heres the error:

error
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now