Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

web part not doing anything on selected index change.

$
0
0

My code is below. I tried to remote debug but when I do the breakpoint will not be hit.  No symbols have been loaded for this document.  When I bring up the modules my dll doesn't appear in there.  If anyone can see anything wrong with my code please advise

using System;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Windows.Forms;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace PurchasingPortal.Vendor.DropDown
{
    [ToolboxItemAttribute(false)]
    public class DropDown : WebPart
    {
        String drpListSelected = "";
        DropDownList drpList = new DropDownList();

        protected override void CreateChildControls()
        {
            SPSite site = SPContext.Current.Site;
            SPWeb web = SPContext.Current.Web;
            SPQuery query = new SPQuery();
            SPList list1 = web.Lists.TryGetList("Vendor");
            if (list1 != null)
            {
                DataTable dtvendor = new DataTable();
                dtvendor = list1.GetItems(query).GetDataTable();
                drpList.DataSource = dtvendor;
                drpList.DataTextField = "Title";
                drpList.DataValueField = "ID";
                drpList.DataBind();
                Controls.Add(drpList);

              //  drpList.SelectedIndexChanged += new EventHandler(this.ddlAllLists_SelectedIndexChanged);
                drpList.SelectedIndexChanged += new EventHandler(drpList_SelectedIndexChanged);
            }
        }

      //  void ddlAllLists_SelectedIndexChanged(object sender, EventArgs e)
        void drpList_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                //set the selected value and logic
                drpListSelected = drpList.SelectedValue;
                global::System.Windows.Forms.MessageBox.Show(drpListSelected);
                this.Page.Response.Redirect("http://drive.penskeautomotive.com/corporateservices/purchasing/Lists/Vendor/DispFormVendor.aspx?iD="+ drpListSelected);

            }
            catch (Exception ex)
            {
                //  LogManger.WriteLog(" Error in EventCalendarWebPart.cs ddlAllLists_SelectedIndexChanged()" + ex.ToString());
                Console.WriteLine(" Error in DropDown.cs ddlAllLists_SelectedIndexChanged()" + ex.ToString());
            }
        }
        protected override void Render(HtmlTextWriter output)
        {
            EnsureChildControls();
            base.RenderContents(output);
        }
    }
}


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>