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

  • SEARCH
  • Home
  • 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 3432222
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:25:21+00:00 2026-05-18T07:25:21+00:00

I have a function like this /// /// This function binds the emplist drop

  • 0

I have a function like this

///
/// This function binds the emplist drop down for mentor user.
///

    private void BindEmpDropDownForMentor()

    {

        string strSelectMentorQuery = "SELECT FIRST_NAME + ' ' + LAST_NAME AS NAME FROM M_USER_DETAILS MUD INNER JOIN M_LEADERLED MLL "
               + "ON MLL.LED_ID = MUD.PK_ID WHERE MLL.LEADER_ID = '" + Session["UserID"].ToString()
               + "' AND MUD.ACTIVE = 1 AND MLL.START_DATE <= Getdate() AND"
               + " MLL.END_DATE > Getdate()";

        OleDbConnection oleConnection = new OleDbConnection(ConfigurationSettings.AppSettings["SQLConnectionString"]);
        OleDbCommand oleCommand = new OleDbCommand(strSelectMentorQuery, oleConnection);

        try
        {
            //Open Connection
            oleConnection.Open();

            //Set Datasource and close connection   
            cmbempList.DataSource = oleCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
            cmbempList.DataValueField = "";
            cmbempList.DataTextField = "NAME";

            //Bind the Dropdown
            cmbempList.DataBind();

            //Add a new item 'ALL TEAM MEMBERS' to the member list
            cmbempList.Items.Insert(0, new ListItem("ALL TEAM MEMBERS", "0"));
            cmbempList.SelectedIndex = 0;

            GridViewDataShowBy = cmbempList.SelectedValue;

        }
        catch (Exception ex)
        {
            ExceptionLogger.LogException(ex);
        }
        finally
        {
            // Close the connection when done with it.
            oleConnection.Close();
        }

    }

But on selected change event of cmbempList, format exception error is being caught saying this that input string was not in correct form in the bold line below

protected void cmbempList_SelectedIndexChanged(object sender, EventArgs e)

    {

        gvLeaveList.CurrentPageIndex = 0;
        dgDaysAbsent.CurrentPageIndex = 0;

        **if (!(Convert.ToInt32(cmbempList.SelectedValue) > 0))
        {**
            if (this.Session["RoleID"].ToString() == "1")
            {
                cmbLeads.ClearSelection();
                cmbLeads.SelectedIndex = cmbLeads.Items.IndexOf(cmbLeads.Items.FindByValue(this.Session["UserID"].ToString()));
            }
        }

        GridViewDataShowBy = cmbempList.SelectedValue.ToString();

        if (cmbempList.SelectedValue != "0" && cmbempList.SelectedValue != "")
        {
            Page.Title = cmbempList.SelectedItem.Text + " | Leave List | "
                       + OrganizationManager.GetCurrentOrganizationName(Session["OrgID"]);
        }
        else
        {
            Page.Title = "Leave List | "
                       + OrganizationManager.GetCurrentOrganizationName(Session["OrgID"]);
        }

        PopulateLeaveList(GridViewDataShowBy, "0");
        BindLeaveListGrid(GridViewDataShowBy, cmbLeads.SelectedValue.ToString());
    }
  • 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-18T07:25:22+00:00Added an answer on May 18, 2026 at 7:25 am

    It is because cmbempList’s DataValueField is being set to an empty string in the BindEmpDropDownForMentor method.

    cmbempList.DataValueField = "";
    

    This will cause cmbempList’s values to be bound to the values in the DataTextField which are strings. When the SelectedIndexChange event is called it tries to parse the strings to an Int32 which is throwing the exception.

    Convert.ToInt32(cmbempList.SelectedValue) > 0
    

    To fix it you can add an aliased ID field in the SQL query and set the cmbempList.DataValueField to that ID name which is probably your intent.

    For example in BindEmpDropDownForMentor make this edit to your query:

    string strSelectMentorQuery = "SELECT FIRST_NAME + ' ' + LAST_NAME AS NAME, MLL.LED_ID AS ID FROM M_USER_DETAILS MUD INNER JOIN M_LEADERLED MLL "
                   + "ON MLL.LED_ID = MUD.PK_ID WHERE MLL.LEADER_ID = '" + Session["UserID"].ToString()
                   + "' AND MUD.ACTIVE = 1 AND MLL.START_DATE <= Getdate() AND"
                   + " MLL.END_DATE > Getdate()";
    

    And assign your DataValueField to this:

    cmbempList.DataValueField = "ID";

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume I have a function template like this: template<class T> inline void doStuff(T* arr)
So I have something like this: var xmlStatement:String = xmlObject.node[3].@thisValue; What mystery function do
I have a function that looks like this class NSNode { function insertAfter(NSNode $node)
I have a function that looks something like this: //iteration over scales foreach ($surveyScales
So I have a function that looks something like this: float function(){ float x
I have a function that I use to add vectors, like this: public static
I have multiple setTimeout functions like this: function bigtomedium(visiblespan) { visiblespan.removeClass('big').addClass('medium'); setTimeout(function(){ mediumtosmall(visiblespan);},150); };
Ok, I have one JavaScript that creates rows in a table like this: function
I have a string that looks like this: Name1=Value1;Name2=Value2;Name3=Value3 Is there a built-in class/function
I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>

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.