主题:一个小问题,帮我解决一下
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{ public class car
{ private string color;
private int chelun=4;
public string Color
{
get
{
return color;
}
set
{
color=value;
}
}
public int Chelun
{
get
{
return chelun;
}
}
public string getinfo(string a,string b)
{//一个方法
string c="";
switch (a)
{case "#red":
c+="你的车的颜色是红色的<br>轮子共有"+b+"个";
break ;
case "#black":
c+="你的车的颜色是黑色的<br>轮子共有"+b+"个";
break ;
case "#blue":
c+="你的车的颜色是蓝色的<br>轮子共有"+b+"个";
break ;
}
return c;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
car onecar = new car();
onecar.Color = DropDownList1.SelectedValue.ToString();
string a = onecar.Color.ToString();
string b = onecar.Chelun.ToString();
string c = onecar.getinfo(a,b);
Response.Write(c);
}
}
为什么运行时,选择组合框的一项,却没有输出
这个程序没有问题啊
是不是DropDownList1的items里的value设置有总题,该怎么设.
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{ public class car
{ private string color;
private int chelun=4;
public string Color
{
get
{
return color;
}
set
{
color=value;
}
}
public int Chelun
{
get
{
return chelun;
}
}
public string getinfo(string a,string b)
{//一个方法
string c="";
switch (a)
{case "#red":
c+="你的车的颜色是红色的<br>轮子共有"+b+"个";
break ;
case "#black":
c+="你的车的颜色是黑色的<br>轮子共有"+b+"个";
break ;
case "#blue":
c+="你的车的颜色是蓝色的<br>轮子共有"+b+"个";
break ;
}
return c;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
car onecar = new car();
onecar.Color = DropDownList1.SelectedValue.ToString();
string a = onecar.Color.ToString();
string b = onecar.Chelun.ToString();
string c = onecar.getinfo(a,b);
Response.Write(c);
}
}
为什么运行时,选择组合框的一项,却没有输出
这个程序没有问题啊
是不是DropDownList1的items里的value设置有总题,该怎么设.