我是新手
我从数据库里取了一些结果集
SqlConnection conn = null;
  SqlDataAdapter sd = null;
  try
        {
   String connStr = System.Configuration.ConfigurationManager.AppSettings["connstring"];
   
   conn = new SqlConnection(connStr);
   conn.Open();
   
   String sql = " select * from music order by id desc";
   
   sd = new SqlDataAdapter(sql, conn);我想吧这个sd里的数据放到html里,遍历到下面的src和a标签里的url,该怎么做?
<div style="margin:15px ; height:50px;  " >
<img src="images/head/1.jpg" width="50" height="50" />
    
<A href="">罗志祥</A></div> 

解决方案 »

  1.   

    <img> 和<A> 都用服务器段控件或者HtmlControl吧。
      

  2.   

    用一个服务器label(名字:lblText)空间,在后台代码编写其Text值。
    写个循环读取sd = new SqlDataAdapter(sql, conn);中的数据,
    sd = new SqlDataAdapter(sql, conn);可以用dataReader
    while(sd.Read()){
          lblText.Text+="<img src="参数1" />"
       lblText.Text+="<a href="参数2" ></a>"
    }