| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1389 人关注过本帖
标题:怎么获得数据,并显示
只看楼主 加入收藏
yyjyyj123
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-4-5
收藏
 问题点数:0 回复次数:0 
怎么获得数据,并显示
<table>
   <tr>
       <td>xxx:<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("image") %>'/></td>
    </tr>
    <tr>
       <td>xxx:<asp:Label ID="Label1" runat="server" Text='<%# Eval("id") %>' /> </td>
    </tr>              
     <tr><td>xxx:<asp:Label ID="RestName" runat="server" Text='<%# Eval("name") %>' /></td>
      </tr>
</table>

            SqlConnection conn = new  SqlConnection("server=.;database=RestOL;uid=sa;pwd=123456;");
            conn.Open();
            SqlCommand sql = new SqlCommand("select * from Dishes ", conn); //有3列
            SqlDataAdapter sda = new SqlDataAdapter(sql);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            int n = ds.Tables[0].Rows.Count;
            for (int i = 0; i < n; i++)
            {
               
                    this.Image1.ImageUrl = ds.Tables[0].Rows[i][0].ToString();
                    this.Label1.Text = ds.Tables[0].Rows[i][1].ToString();
                    this.RestName.Text = ds.Tables[0].Rows[i][2].ToString();

               
            }
            conn.Close();

[此贴子已经被作者于2017-4-5 22:40编辑过]

2017-04-05 22:10
快速回复:怎么获得数据,并显示
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014382 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved