Solved

When I bind my asp.net dropdownlist control I get the error "System.Web.HttpException was unhandled by user code"??

Posted on 2009-06-30
6
279 Views
Last Modified: 2013-12-17
I have written the attached code within the edititemtemplate of my asp.net 3.5 listview control. For some reason I seem to get the error: "System.Web.HttpException was unhandled by user code"?? I have used this kind of binding before with no issues, the only difference this time being that my page is being populated by a value from the query string.

Thanks.
<asp:DropDownList 

                                                    ID="InterviewerEditDDL" 

                                                    runat="server" 

                                                    DataSourceID="InterviewerEditDataSource" 

                                                    DataTextField="InterviewerName" 

                                                    DataValueField="InterviewerID" 

                                                    CssClass="ddlTxtBoxInterviewer" 

                                                    SelectedValue='<%# Bind("InterviewerID") %>'>

                                                </asp:DropDownList>

                                                <asp:LinqDataSource 

                                                    ID="InterviewerEditDataSource" 

                                                    ContextTypeName="HRsystemDataContext" 

                                                    TableName="ApplicantInterviewers" 

                                                    runat="server" 

                                                    onselecting="InterviewerEditDataSource_Selecting" />

Open in new window

0
Comment
Question by:Shepwedd
  • 4
  • 2
6 Comments
 
LVL 15

Expert Comment

by:jinal
ID: 24746683
Hello,

remove this  and try SelectedValue='<%# Bind("InterviewerID") %>'>
0
 

Author Comment

by:Shepwedd
ID: 24746716
jinal,

I have that already referenced in my attached code?

I'm not too sure what you want me to remove either.

Thanks.
0
 
LVL 15

Expert Comment

by:jinal
ID: 24746766
<asp:DropDownList
                                                    ID="InterviewerEditDDL"
                                                    runat="server"
                                                    DataSourceID="InterviewerEditDataSource"
                                                    DataTextField="InterviewerName"
                                                    DataValueField="InterviewerID"
                                                    CssClass="ddlTxtBoxInterviewer"                                                    
                                                </asp:DropDownList>
                                                <asp:LinqDataSource
                                                    ID="InterviewerEditDataSource"
                                                    ContextTypeName="HRsystemDataContext"
                                                    TableName="ApplicantInterviewers"
                                                    runat="server"
                                                    onselecting="InterviewerEditDataSource_Selecting" />


0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Shepwedd
ID: 24746865
jinal,

I have tried that but it flags the error: "Object reference not set to an istance of an object". I have also tried to set the selectedvalue (code attached) within the onitemupdating event of my listview (my drop down list control is within the edititemtemplate of a listview control) but again I get the above error?
protected void lvInterviewers_ItemUpdating(object sender, ListViewUpdateEventArgs e)

    {

        DropDownList ddlEditInterviewerID = (DropDownList)lvInterviewers.Items[e.ItemIndex].FindControl("InterviewerEditDDL");

        e.NewValues["InterviewerID"] = ddlEditInterviewerID.SelectedValue;

    }

Open in new window

0
 
LVL 15

Expert Comment

by:jinal
ID: 24747094
I think that is problem related to LinqDataSource.
0
 
LVL 15

Accepted Solution

by:
jinal earned 500 total points
ID: 24749124
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now