Solved

SELECT INDEX of drop down list

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now