Solved

SELECT INDEX of drop down list

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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