C#.net如何将数据库中选定的值显示在label中
publicvoidddlClassBind4(LabelddlName,DropDownListddlName1,DropDownListddlName2,DropDo...
public void ddlClassBind4(Label ddlName, DropDownList ddlName1, DropDownList ddlName2, DropDownList ddlName3)
{
string ClassName = ddlName1.SelectedValue;
string GoodsName = ddlName2.SelectedValue;
string GoodsIntroduce = ddlName3.SelectedValue;
string P_Str_SqlStr = "select MemberPrice from tb_huishou where ClassName = '" + ClassName + "' and GoodsName ='" + GoodsName + "'and GoodsIntroduce='" + GoodsIntroduce + "'";
SqlConnection myConn = dbObj.GetConnection();
SqlDataAdapter da = new SqlDataAdapter(P_Str_SqlStr, myConn);
DataSet ds = new DataSet();
da.Fill(ds, "P_Str_SqlStr");
ddlName.Text = ds.Tables["P_Str_SqlStr"].Columns[0].ToString();
//ddlName.DataValueField = ds.Tables["huishou"].Columns[0].ToString();
ddlName.DataBind();
}
我想显示出具体价格,可显示出来的是MemberPrice 展开
{
string ClassName = ddlName1.SelectedValue;
string GoodsName = ddlName2.SelectedValue;
string GoodsIntroduce = ddlName3.SelectedValue;
string P_Str_SqlStr = "select MemberPrice from tb_huishou where ClassName = '" + ClassName + "' and GoodsName ='" + GoodsName + "'and GoodsIntroduce='" + GoodsIntroduce + "'";
SqlConnection myConn = dbObj.GetConnection();
SqlDataAdapter da = new SqlDataAdapter(P_Str_SqlStr, myConn);
DataSet ds = new DataSet();
da.Fill(ds, "P_Str_SqlStr");
ddlName.Text = ds.Tables["P_Str_SqlStr"].Columns[0].ToString();
//ddlName.DataValueField = ds.Tables["huishou"].Columns[0].ToString();
ddlName.DataBind();
}
我想显示出具体价格,可显示出来的是MemberPrice 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询