asp.net在下拉菜单中选择一项会反应别的结果
这是数据访问类用的方法:publicstaticIList<OrderInfo>GetOrderById1(intIfAffirm){DBHelpdb=newDBHelp...
这是数据访问类用的方法:
public static IList<OrderInfo> GetOrderById1(int IfAffirm)
{ DBHelp db = new DBHelp();
List<OrderInfo> list = new List<OrderInfo>();
string sql = "select * from OrderInfo where IfAffirm='1'";
SqlDataReader reader = db.GetReader(sql, new SqlParameter("1", IfAffirm));
if (reader.Read())
{ OrderInfo Order = new OrderInfo();
Order.OrderID = (int)reader["OrderID"];
Order.OrderPrice = (decimal)reader["OrderPrice"];
Order.Wares=WaresoService.GetWaresById((int)reader["WaresID"]);
Order.OrderTime = (DateTime)reader["OrderTime"];
Order.OrderNum = (int)reader["OrderNum"];
Order.LogisticsWay = (string)reader["LogisticsWay"];
Order.User = UserService.GetuserByid((int)reader["UserID"]);
Order.UserPhone = (string)reader["UserPhone"];
Order.IfAffirm = (int)reader["IfAffirm"];
list.Add(Order);}
reader.Close();
db.CloseConnection();
return list; } 展开
public static IList<OrderInfo> GetOrderById1(int IfAffirm)
{ DBHelp db = new DBHelp();
List<OrderInfo> list = new List<OrderInfo>();
string sql = "select * from OrderInfo where IfAffirm='1'";
SqlDataReader reader = db.GetReader(sql, new SqlParameter("1", IfAffirm));
if (reader.Read())
{ OrderInfo Order = new OrderInfo();
Order.OrderID = (int)reader["OrderID"];
Order.OrderPrice = (decimal)reader["OrderPrice"];
Order.Wares=WaresoService.GetWaresById((int)reader["WaresID"]);
Order.OrderTime = (DateTime)reader["OrderTime"];
Order.OrderNum = (int)reader["OrderNum"];
Order.LogisticsWay = (string)reader["LogisticsWay"];
Order.User = UserService.GetuserByid((int)reader["UserID"]);
Order.UserPhone = (string)reader["UserPhone"];
Order.IfAffirm = (int)reader["IfAffirm"];
list.Add(Order);}
reader.Close();
db.CloseConnection();
return list; } 展开
3个回答
展开全部
代码拿出来,绑定下拉菜单的代码
和下拉菜单选中的代码
和下拉菜单选中的代码
追问
public static IList GetOrderById1(int id)
{
return OrderService.GetOrderById1(id);
}
这是业务逻辑类方法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
绑定value值和text值时绑定的列可能不正确
追问
是一样的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
html
<asp:DropDownList ID="ddl" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
后台
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
int index = ddl.SelectedIndex;
if(index==0){//如果是第1项,怎么怎么样.}
else if(index==1){//如果是第2项,怎么怎么样.}
.......
}
<asp:DropDownList ID="ddl" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
后台
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
int index = ddl.SelectedIndex;
if(index==0){//如果是第1项,怎么怎么样.}
else if(index==1){//如果是第2项,怎么怎么样.}
.......
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询