惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
Project Zero
Project Zero
E
Exploit-DB.com RSS Feed
S
Secure Thoughts
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
WordPress大学
WordPress大学
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Hacker News: Ask HN
Hacker News: Ask HN
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hacker News: Front Page
F
Full Disclosure
Latest news
Latest news
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
T
Troy Hunt's Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
G
GRAHAM CLULEY
Forbes - Security
Forbes - Security
V
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
P
Privacy International News Feed
C
Check Point Blog
N
News and Events Feed by Topic

博客园 - Gerald1983

[转载]AJAX 框架 用 Asp.net ajax 还是 Jquery ? [转]触发器 Excel导出报错 Delete File - Gerald1983 - 博客园 SQLServer Service Can't Start - Gerald1983 DataSource of GridView is Excel - Gerald1983 SQL - Using CASE in a JOIN SQL SERVER 与ACCESS、EXCEL的导入导出(转载) Asp.net页面的生命周期 Asp.net页面的生命周期 DataGrid /GridView分页(sqlserver/oracle)-----转载 sql语句中包括单引号和双引号的问题 XmlDocument操作xml文档 (转) Ajax实例转载 一个Ajax实例(成本项目) Oracle存储过程编写经验和优化措施(转) GridView的美化 - Gerald1983 数据绑定时的前台页面上的逻辑判断 (转) C#代码与javaScript函数的相互调用(转)
如何去掉DataTable中的重复行(新增.net 2.0中最新解决方法---简便) (转)
Gerald1983 · 2008-06-23 · via 博客园 - Gerald1983

.net 1.1中的解决方法(转)
1建立一个DataSetHelper类(DataSetHelper.cs)

2 建立一个Web窗体,在page_load中写下面的代码

       DataSet ds;
        DataSetHelper dsHelper;
        ds 
= new DataSet();
        dsHelper 
= new DataSetHelper(ref ds);

        
// Create source table
        DataTable dt = new DataTable("Orders");
        dt.Columns.Add(
"EmployeeID", Type.GetType("System.String"));
        dt.Columns.Add(
"OrderID", Type.GetType("System.Int32"));
        dt.Columns.Add(
"Amount", Type.GetType("System.Decimal"));

        dt.Rows.Add(
new object[] "Sam"525.00 });
        dt.Rows.Add(
new object[] "Tom"750.00 });
        dt.Rows.Add(
new object[] "Sue"911.00 });
        dt.Rows.Add(
new Object[] "Tom"127.00 });
        dt.Rows.Add(
new Object[] "Sam"14512.00 });
        dt.Rows.Add(
new Object[] "Sue"1517.00 });
        dt.Rows.Add(
new Object[] "Sue"222.50 });
        dt.Rows.Add(
new object[] "Tom"243.00 });
        dt.Rows.Add(
new object[] "Tom"3378.75 });

        ds.Tables.Add(dt);
       DataTable td
=dsHelper.SelectDistinct("DistinctEmployees", ds.Tables["Orders"], "EmployeeID");
       
this.GridView1.DataSource = td;
       
this.GridView1.DataBind();

 .net 2.0中的解决方法(原创)

public DataTable GetTopSearch()
        
{
            DataSet dsKeyword 
= dal.GetKeyword();
            DataSet dsTopSearch 
= new DataSet();
            
for (int i = 0; i < 4; i++)
            
{
                
string keyword = dsKeyword.Tables[0].Rows[i]["Name"].ToString();
                
string condition = dsKeyword.Tables[0].Rows[i]["SearchCondition"].ToString();
                dsTopSearch.Merge(dal.GetTopSearch(keyword,condition));
            }

            
return dsTopSearch.Tables[0].DefaultView.ToTable(true"ID","Name","Author","Publisher","PublishDate","TypeName","Price","SalePrice","SavePrice","Rebate","ImagePath","ContentIntro");
        }


先把DataTable转成DataView,再通过DataView.ToTable()转回DataTable,ToTable()方法中有一个重载可以轻松消除重复行.
注:该重载的第二个参数为要保存的字段名.