VS错误提示(64): Cannot convert type 'string' to 'int'
-------------------------------------------------------if ((int)DropDownList1.SelectedValue=1)
{   
...............
}
else if((int)DropDownList1.SelectedValue=2)
{
................
}
else if((int)DropDownList1.SelectedValue=3)
{
.................
}
--------------------------------------------------------数据类型转换不成功,是不是if语句内不让转换啊,怎么改才行?谢谢

解决方案 »

  1.   

    请注意判断等于是==,而不是=if (int.Parse(DropDownList1.SelectedValue)==1) 
    {    
    ............... 

    else if(int.Parse(DropDownList1.SelectedValue)==2) 

    ................ 

    else if(int.Parse(DropDownList1.SelectedValue)==3) 

    ................. 
      

  2.   

    if (int32.Parse(DropDownList1.SelectedValue)==1) 
    {    
    ............... 

    else if(int32.Parse(DropDownList1.SelectedValue)==2) 

    ................ 

    else if(int32.Parse(DropDownList1.SelectedValue)==3) 

    .................