Solved

SELECT INDEX of drop down list

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

18 Experts available now in Live!

Get 1:1 Help Now