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
286 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

24 Experts available now in Live!

Get 1:1 Help Now