Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6180249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:48:48+00:00 2026-05-24T00:48:48+00:00

This is my code in aspx: <EditItemTemplate> <asp:DropDownList ID=DropDownList1 runat=server DataSourceID=SqlDataSource2 SelectedValue='<%#GetSYSACCID(Eval(SYSACCID))%>’ DataTextField=UserName DataValueField=SYSACCID>

  • 0

This is my code in aspx:

 <EditItemTemplate>           
    <asp:DropDownList ID="DropDownList1" runat="server" 
         DataSourceID="SqlDataSource2" SelectedValue='<%#GetSYSACCID(Eval("SYSACCID"))%>'
         DataTextField="UserName" DataValueField="SYSACCID">
    </asp:DropDownList>
  </EditItemTemplate>

DropDownList is inside EditItemTemplate of TemplateField in gridview. The GetSYSACCID is a function defined in aspx.cs. Problem is when Eval("SYSACCID") is null, GetSYSACCID returns null and so error is thrown. How can I handle this? I know this looks easy but still it’s giving me a pain.

Thanks in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:48:50+00:00Added an answer on May 24, 2026 at 12:48 am

    You can do something like…

    SelectedValue='<%# GetSYSACCID(Eval("SYSACCID") == null ? 0 : Eval("SYSACCID"))%>'
    

    You have default value to handle null value. e.g.

    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" AppendDataBoundItems="true"
                SelectedValue='<%#GetSYSACCID(Eval("SYSACCID"))%>' DataTextField="UserName" DataValueField="SYSACCID" >
                <asp:ListItem Value="0" Text="---Select---"></asp:ListItem>
            </asp:DropDownList>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a this aspx-code: (sample) <asp:DropDownList runat=server ID=ddList1></asp:DropDownList> With this codebehind: List<System.Web.UI.WebControls.ListItem> colors
In the aspx code view , we can code like this: <asp:ListBox runat=server> <asp:ListItem
If I use this code on my aspx page: <asp:BulletedList ID=listClientContacts runat=server> <asp:ListItem><b>My Name</b></asp:ListItem>
I have this code in my aspx page: <form id=form2 runat=server> <asp:ScriptManager ID=ItemsScriptManager runat=server
I have this code in my .aspx file <asp:UpdatePanel runat=server ID=UpdatePanel1 UpdateMode=Conditional> <ContentTemplate> <asp:PlaceHolder
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I have the following ASPX code: <asp:ScriptManager ID=ScriptManager1 runat=server /> <asp:UpdatePanel runat=server ID=UpdatePanel UpdateMode=Conditional>
Language: asp This is sample of my code: str = www.example.com/gotobuy.aspx?id=1234 key_word = .obuy.
I have this code in .aspx page <gridview ..... <columns> ............ ........... <asp:templatefield Visible=true
I am using this code... Server.Transfer(/Student/StudentControlPanel.aspx?username= + username); And getting the following Exception: InvalidOperationException

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.