C#
未将对象引用设置到对象的实例我想设置 Web的主题,2 个主题myfirst 和 mysecond ,Dropdownlist1 有 2个ListItem ,text为myfirst和mysecond, vlaue也为 myfirst 和mysecond,选择 myfirst这个Item的时候就显示主题myfirst ,选择..就显示..可是选择后要设置DropdownList的选中项 所以定义了 ListItem item = DropDownList1.Items.FindByText(theme);可编译提示“未将对象引用设置到对象的实例” 高手帮忙~!!!!感恩~!!{{{在线等}}}
public partial class MSSS : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
void Page_PreInit(object sender, EventArgs e)
{
string theme;
if (Request.QueryString[ "theme "] == null)
{
theme = "myfirst ";
}
else
{
theme=Request.QueryString[ "theme "];
}
Page.Theme = theme;
ListItem item = DropDownList1.Items.FindByText(theme);
if (item != null)
{
item.Selected = true;
}
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
string id = TreeView1.SelectedValue;
MultiView1.ActiveViewIndex =Convert.ToInt16(id);
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string Url = Request.Path + &