hi eveyone
i have to big problem so
this problem have two datatable
first table like
column1----column2----column3
row11-----row21-----row31
row12-----row22-----row32
i want to inset to other table
column1---row11
column1---row12
column2---row21
column2---row22
column3---row31
column3---row32
my code:
DataTable orjiTable = new DataTable();
DataTable gecicitable = new DataTable();
adptr.Fill(gecicitable);
// orjiTable.Columns.Add(gecicitable.Columns[0].ColumnName.ToString());
// MessageBox.Show(gecicitable.Columns[0].ColumnName.ToString());
foreach (DataRow inRow in gecicitable.Rows)
{
string newColName = inRow[0].ToString();
MessageBox.Show(newColName);
orjiTable.Columns.Add(newColName);
DataRow newRow1 = orjiTable.NewRow();
string den = gecicitable.Columns[0].ColumnName.ToString();
newRow1[0] = den;
orjiTable.Rows.Add(den);
}
for (int rCount = 1; rCount <= gecicitable.Columns.Count - 1; rCount++)
{
DataRow newRow = orjiTable.NewRow();
newRow[0] = gecicitable.Columns[rCount].ColumnName.ToString();
MessageBox.Show(gecicitable.Columns[rCount].ColumnName.ToString());
for (int cCount = 0; cCount <= gecicitable.Rows.Count - 1; cCount++)
{
string colValue = gecicitable.Rows[cCount][rCount].ToString();
newRow[cCount + 2] = colValue;
MessageBox.Show(colValue);
}
orjiTable.Rows.Add(newRow);
}
when runnig this code output :
row11--------row12
column1
column1
row21--------row22
row31--------row32
input taple
column1-----column2-----column3
row11--------row21-------row31
row12--------row22-------row32
i want to like this output:
column1---- row11
column1---- row12
column2---- row21
column2---- row22
column3---- row31
column3---- row32