一个operation类:operation op = new operation();
txtTitle.Text = op.Rtitle(DropDownList2.SelectedItem.Text.Trim());//未将对象引用设置到对象的实例这是为什么呢!~?
应该怎样改呢?

解决方案 »

  1.   

    是DropDownList2.SelectedValue吧!  
      

  2.   

    op.Rtitle=DropDownList2.SelectedItem.Text.Trim();
    txtTitle.Text=op.Rtitle.ToString();
      

  3.   


    Rtitle 是一个方法来的
      

  4.   

    DropDownList2.SelectedItem列表里是空的,没有选中任何一个,就空引用了哦,加几项进去吧
      

  5.   


    DropDownList2有数据的,它绑定了SQL的一个列的值!
      

  6.   

    不太可能呀,你放开来写
    operation op = new operation(); DropDownList a;
    ListItem b;
    String c;
    String d;        a = DropDownList1;
            b = a.SelectedItem;
            c = b.Text;
            d = c.Trim;txtTitle.Text = op.Rtitle(d);看看哪行错
      

  7.   

    DropDownList2.SelectedItem.Text.Trim());里面没有绑定吧
      

  8.   


    operation op = new operation(); 
    if(DropDownList2.SelectedItem != null)
         txtTitle.Text = op.Rtitle(DropDownList2.SelectedItem.Text.Trim
    else
         txtTitle.Text = "";
      

  9.   

    嗯,我用这个大哥的代码测试过,确实是没值。。
    但我在页面也确实可以读出DropDownList2.SelectedItem 是有值的。。
    我想是,没默认值之类的。。是不是应该在DropDownList2的属性中设置点什么呢?!?