Solved

SELECT INDEX of drop down list

Posted on 2011-03-21
2
255 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
  • 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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