从database读入model,pURL,两列,model用来显示,pURL用来加上链接地图片。代码不知道要怎么写,求。以下的代码,我不知道要怎么把pURL的这个值,加到<a href></a>这里。不能用控件,因为服务器不支持,只能手写代码去连接。就相当于把每个model的都变成超链接,每一个model都和它自己的URL对应好,做成绑定,但是我不知道要代码怎么写。
        String strcon = "server=WORKSTAT-EEE298\\SQL2005;Initial Catalog=MPTV;Integrated Security=True; ";
        
        SqlConnection myConn = new SqlConnection(strcon);
        SqlDataAdapter da = new SqlDataAdapter("select model from PHONEMODEL where PHONEMODEL.factory= '" + DropDownList1.SelectedItem.Value + "'", myConn);        DataSet ds = new DataSet();//创建数据集         da.Fill(ds);//填充         myConn.Close();        int jlh = 0;        Response.Write(" <div id='left' style='background-color: #1f3d58; text-align: center; height: 510px;'>");        Response.Write(" <table border='1' class='style2'");
        for (int i = 0; i < ds.Tables[0].Rows.Count / 6; i++)
        {
            Response.Write(" <tr>");
            for (int j = 0; j < 6; j++)
            {
                Response.Write(" <td> <a href='?????' target='_blank'>" + ds.Tables[0].Rows[jlh]["model"].ToString() + " </a> </td>");
                jlh++;
            }
            Response.Write(" </tr>");
        }
        if (ds.Tables[0].Rows.Count - 1 >= jlh)
        {
            Response.Write(" <tr>");
            for (int j = 0; j < 6; j++)
            {
                if (jlh <= ds.Tables[0].Rows.Count - 1)
                {
                    Response.Write(" <td> <a href='?????'>" + ds.Tables[0].Rows[jlh]["model"].ToString() + " </a> </td>");
                    jlh++;
                }
                else
                    Response.Write(" <td>&nbsp; </td>");
            }
            Response.Write(" </tr>");
        }
        for (int ii = (ds.Tables[0].Rows.Count / 6) + 1; ii <= 10; ii++)
        {
            Response.Write(" <tr>");
            for (int j = 0; j < 6; j++)
            {
                Response.Write(" <td>&nbsp; </td>");
            }
            Response.Write(" </tr>");
        }
        Response.Write(" </table>");
        Response.Write("</div>");

解决方案 »

  1.   

    这个还不简单吗? public void Test(DataSet ds)
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string name = ds.Tables[0].Rows[0]["email"].ToString();
    ????处,加上name        }
        }
      

  2.   

    Response.Write(" <td> <a href='"+ds.Tables[0].Rows[jlh]["pURL"].ToString() +"'>" + ds.Tables[0].Rows[jlh]["model"].ToString() + " </a> </td>");
      

  3.   

    如果model是全路径直接绑定得到就可以了,如果只是名字,在前面加上路径在把名字连接起来就可以了
      

  4.   

    不是很明白,你注意没,我代码里只读了model,没读pURL这个值,因为我不知道要怎么处理读出来的pURL,放在哪里,所以你的代码我不能直接用。还有,这个代码要放在哪里?我的代码是直接在 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)里写的。真的是新手,见笑了