在线等——Ilist传值
SQLDAL:
private const string SQL_SELECT_JBXX = "select jbxx_xm from TdrSys_jbxx where jbxx_sfzh=@sfzh";
public IList<TdrSys_jbxx> searchjbxxBySfzh(string sfzh)
{
IList<TdrSys_jbxx> XinXi = new List<TdrSys_jbxx>();
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["link"].ConnectionString);
cn.Open();
SqlCommand cmd = new SqlCommand(SQL_SELECT_JBXX, cn);
cmd.Parameters.AddWithValue("@sfzh", sfzh);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow myDataRow in dt.Rows)
{
var obj = new TdrSys_jbxx();
XinXi.Add(obj);
}
return XinXi;
}
aspx.cs:
if (!IsPostBack)
{
IList<TdrSys_jbxx> list = new List<TdrSys_jbxx>();
string Num = Session["sfzh"].ToString();
BTdrSys_jbxx UserID = new BTdrSys_jbxx();
list = UserID.searchjbxxBySfzh(Num);
foreach(TdrSys_jbxx xx in list)
{
xm.Text += xx.jbxx_xm;
}
}
为啥xm这个lable得不到值,帮我看看,帮我改一下,感激不尽!
------解决方案--------------------
一步步调试,看看问题在哪里!