日期:2014-05-18  浏览次数:20475 次

求教用ASP.net解决个从数据库取数据传入到表格的问题
数据库里有以下数据
770 向显飘 长线 2008-07-09 00:00:00.000 1000.00 19.00 深圳A线
1306 杜永洪 长线 2008-07-10 00:00:00.000 500.00 6.50 深圳B线
992 唐长友 短线 2008-07-11 00:00:00.000 50.00 .45 111111111
996 张凤全 长线 2008-07-12 00:00:00.000 5000.00 95.00 222222
770 向显飘 长线 2008-07-01 00:00:00.000 1000.00 19.00 深圳A线
770 向显飘 中线 2008-07-02 00:00:00.000 2000.00 22.00 深圳A线
770 向显飘 短线 2008-07-03 00:00:00.000 2500.00 20.00 深圳A线
770 向显飘 中线 2008-07-04 00:00:00.000 2000.00 22.00 深圳A线
770 向显飘 中线 2008-07-05 00:00:00.000 2000.00 22.00 深圳A线
770 向显飘 长线 2008-07-06 00:00:00.000 5000.00 95.00 深圳A线
770 向显飘 长线 2008-07-07 00:00:00.000 20000.00 380.00 深圳A线
770 向显飘 短线 2008-07-08 00:00:00.000 6000.00 48.00 深圳A线
上头的要求是这样的:
取姓名为"向显飘" 把他的相关数据都取出来用ASP.net写到前台客户端的已经定义好的表格里去
但是表格不能动态的和数据库的数据绑在一起 都是一个表格显示它一条的记录 我想把他相关的数据都写入到一个表格里显示出来
其他的人员的数据也是单独做个表格 表格样式是一样的 只是数据不同
该怎么写呀 有人可以帮助我么。


------解决方案--------------------
股票的信息么,有没有啥内幕透露下啊,呵呵
将你要显示的信息查出放入一个datatable中,然后将datatable中的数据放入表格里不行吗
------解决方案--------------------
不懂你的意思?
直接做个Datebind()不行吗?
------解决方案--------------------
看来你没有理解绑定的意义!
------解决方案--------------------
用repeater,datagrid,datalist,gridview 都可实现. 
关键是lz必须要学会一种.网上找个基础例程看看.
------解决方案--------------------
关键我是没看懂LZ表达的意思
------解决方案--------------------
string sql = "sql语句";
SqlConnection myconn = new SqlConnection();
myconn.ConnectionString = "server=(local);database=data;uid=sa;pwd=";
myconn.Open();
SqlCommand com = new SqlCommand(sql, myconn);
SqlDataReader reader = com.ExecuteReader();
while (reader.Read())

response.write("<table>");
response.write("<tr>");
response.write("<td>");
response.write(reader["字段名"].ToString());
....................
response.write("</td>");
response.write("</tr>");
response.write("</table>");
}
------解决方案--------------------
一个表格显示它一条的记录?
用GridView不行吗?
------解决方案--------------------
绑定到 GridView 
用 ItemTemple来显示
Eval("字段")
------解决方案--------------------
在html里用个for循环试试
------解决方案--------------------
真的假的哦,你上面才100分,改400分明天一早贴答案给你!
------解决方案--------------------
前台:
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table>
<tr>
<td>
列1
</td>
<td>
列2
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%#DataBinder(Container.DataItem,"字段名1")%>
</td>