what am I missing here?
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
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;
SPList list1 = web.Lists["Vendor"];
var listitems = list1.Fields["Company"];
drpList.DataSource = listitems;
drpList.DataTextField = "Company";
drpList.DataValueField = "ID";
drpList.DataBind();
Controls.Add(drpList);
drpList.SelectedIndexChanged += new EventHandler(this.ddlAllLists_SelectedIndexChanged);
}
void ddlAllLists_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
//set the selected value and logic
drpListSelected = drpList.SelectedValue;
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());
}
}
protected override void Render(HtmlTextWriter output)
{
EnsureChildControls();
base.RenderContents(output);
}
}
}