首页 新闻 搜索 专区 学院

dataset中的一个datatable的输出问题

0
悬赏园豆:100 [已解决问题] 解决于 2008-01-29 15:40
<P>datset里一张datatable表,如何使输出为 <BR>sony: &nbsp; k500 &nbsp; k700 &nbsp; ... <BR>nokia:&nbsp; 2650 &nbsp; 3100 &nbsp; ... <BR><BR>表结构为: <BR>mid &nbsp; typeid &nbsp; phone_type &nbsp; id &nbsp; name <BR>223 &nbsp; &nbsp; 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; k500&nbsp;&nbsp;&nbsp; 3 &nbsp; &nbsp; &nbsp; sony <BR>224 &nbsp; &nbsp; 3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; k700&nbsp;&nbsp;&nbsp;&nbsp;3 &nbsp; &nbsp; &nbsp; sony <BR>...... <BR>235 &nbsp; &nbsp; 5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2650&nbsp;&nbsp;&nbsp;&nbsp; 5 &nbsp; &nbsp; &nbsp; nokia <BR>236 &nbsp; &nbsp; 5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3100&nbsp;&nbsp;&nbsp;&nbsp; 5 &nbsp; &nbsp; &nbsp; nokia <BR>......</P> <P>&nbsp;</P> <P>as.net&nbsp; 的</P>
赚钱第一的主页 赚钱第一 | 初学一级 | 园豆:4
提问于:2008-01-28 15:07
< >
分享
最佳答案
0
新建一个页面拷入以下前台代码: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Photo.aspx.cs" Inherits="samples_Photo" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Created by 沙加, darkangle.cnblogs.com</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="gv1" runat="server" /> <hr /> <h1>Output : </h1> <asp:Literal ID="ltOutput" runat="server" /> </div> </form> </body> </html> 后台: using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class samples_Photo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DataTable dtPhoto = new DataTable(); dtPhoto.Columns.Add("mid"); dtPhoto.Columns.Add("phone_type"); dtPhoto.Columns.Add("name"); DataRow dr = dtPhoto.NewRow(); dr[0] = 223; dr[1] = "k500"; dr[2] = "sony"; dtPhoto.Rows.Add(dr); dr = dtPhoto.NewRow(); dr[0] = 224; dr[1] = "k700"; dr[2] = "sony"; dtPhoto.Rows.Add(dr); dr = dtPhoto.NewRow(); dr[0] = 235; dr[1] = "2650"; dr[2] = "nokia"; dtPhoto.Rows.Add(dr);
沙加 | 老鸟四级 |园豆:3680 | 2008-01-28 17:04
其他回答(2)
0
sony: k500 k700 ... nokia: 2650 3100 ... 里面的...代表什么?
Netprawn | 园豆:125 (初学一级) | 2008-01-28 15:56
0
这个我以前也遇到过,最后硬是把dataset中table的行搜了一遍,主要还是消除重复的行的问题,很不幸的是,我曾看到微软社区有个这样的例子。性能上大打折扣,这就不拿出来献丑了
MartinGao | 园豆:663 (小虾三级) | 2008-01-28 17:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册