Solved

SELECT INDEX of drop down list

Posted on 2011-03-21
2
257 Views
Last Modified: 2012-05-11
I'm trying to automatically select the drop down list item....keeps bombing out

 System.NullReferenceException: Object reference not set to an instance of an object
private void usp_CheckNamedUsers_Selected(Object sender, SqlDataSourceStatusEventArgs e)
      {
		// grab our return value from the stored procedure
        string str_Test = e.Command.Parameters["@bit_ReturnValue"].Value.ToString();

        // if this user doesn't exist in the DB direct them to the new user page
        if(str_Test != "True")
          Response.Redirect("/Recruitment/UserInformation.aspx");

        if (!IsPostBack)
        {
            DataView dvw_DataView_usp_Requisition_SELECT = (DataView)usp_Requisition_SELECT.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView drv_DataRowView in dvw_DataView_usp_Requisition_SELECT)
            {
                // textboxes and labels  
                // cal_RequestDate.Text           = drv_DataRowView["dtm_RequestDate"].ToString();
                txt_JobTitleQueued.Text = drv_DataRowView["vch_JobTitleID"].ToString();
                txt_HiringManagerQueued.Text = drv_DataRowView["int_L1NamedUserID"].ToString();
                txt_LocationQueued.Text = drv_DataRowView["int_LocationID"].ToString();
                txt_PayTypeQueued.Text = drv_DataRowView["int_PositionType"].ToString();
                txt_Split1PIDQueued.Text = drv_DataRowView["vch_PIDSplit1"].ToString();
                txt_Split2PIDQueued.Text = drv_DataRowView["vch_PIDSplit2"].ToString();
                txt_Split3PIDQueued.Text = drv_DataRowView["vch_PIDSplit3"].ToString();
                txt_Split4PIDQueued.Text = drv_DataRowView["vch_PIDSplit4"].ToString();
                txt_FundSourceSplit1.Text = drv_DataRowView["vch_PercentSplit1"].ToString();
                txt_FundSourceSplit2.Text = drv_DataRowView["vch_PercentSplit2"].ToString();
                txt_FundSourceSplit3.Text = drv_DataRowView["vch_PercentSplit3"].ToString();
                txt_FundSourceSplit4.Text = drv_DataRowView["vch_PercentSplit4"].ToString();
                txt_RecruitmentDelayed.Text = drv_DataRowView["vch_RecruitmentDelayed"].ToString();
                txt_RecruitmentUnapproved.Text = drv_DataRowView["vch_RecruitmentUnapproved"].ToString();
                txt_HowWorkAccomplished.Text = drv_DataRowView["vch_HowWorkAccomplished"].ToString();


            }
        }
        ddl_DepartmentLocation.Items.FindByValue(txt_LocationQueued.Text.ToString()).Selected = true;
      }


 <asp:DropDownList 
                            ID="ddl_DepartmentLocation"
                            Width="225px"
                            DataSourceID="usp_Location_SELECT"
                            DataTextField="vch_Location"
                            DataValueField="int_LocationID"
                            TabIndex="6"
                            ToolTip="Select the location that this position will be based at from the list."
                            runat="server">
                          </asp:DropDownList>

Open in new window

0
Comment
Question by:gdspeare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
gdspeare earned 0 total points
ID: 35183710
Answer:

  ddl_DepartmentLocation.SelectedIndex = Convert.ToInt16(txt_LocationQueued.Text);
0
 

Author Closing Comment

by:gdspeare
ID: 35183715
converted text box value to int.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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