i have added an extra column, which is a key column, then i have sorted the DataTable using this key column, now i want to find out duplicate in this DataTable using this key column, if some one help me i will be very happy.
private void cmdShow_Click(object sender, System.EventArgs e)
{
System.IO.StreamReader re = new System.IO.StreamReader("c:/abc.txt");
string word;
ArrayList theList = new ArrayList();
while ((word = re.ReadLine()) != null)
{
theList.Add(word);
}
re.Close();
theList.ToArray(typeof(string));
DataTable name = new DataTable("name");
int counter = 0;
int keyCol=0;
int chick = 0;
string key;
foreach (string theString in theList)
{
DataRow myRow = name.NewRow();
string[] dataColumns = theString.Split(',');
for (int i = 0; i < dataColumns.Length; i++)
{
if(chick == 0)
{
{
name.Columns.Add(dataColumns.GetValue(j).ToString());
}
name.Columns.Add("Key");
}
chick++;
if (i > dataColumns.Length)
break;
myRow[ i ] = dataColumns[ i ];
keyCol = i;
}
if (counter != 0){
key = dataColumns.GetValue(0).ToString().Substring(0, 1) + dataColumns.GetValue(1).ToString().Substring(0, 2) + dataColumns.GetValue(2).ToString().Substring(0, 2);
key = key.ToUpper();
myRow[keyCol+1] = key;
name.Rows.Add(myRow);
}
counter++;
}
name.DefaultView.Sort =
"Key ASC"; this.dataGrid1.DataSource =name;}

I want to Find out duplicate in DataTable using the following code
GapIT
Please do not post duplicate questions on either the same forum or in separate forums. This needlessly adds more posts that others have to go through. Furthermore if someone answers your post in one forum the other posts you have won't have the answer so it doesn't really help anyone.
If you are not sure whether your post was accepted or not (as I have on occasion) then wait a few minutes to give the post time to be pushed to the server and reflected in the list. Sometimes it can take a little while although most times it is immediate.
Thanks and welcome to the forums.
Michael Taylor - 2/16/06