Same code but different result..........?

Discussion about the open-source Phalanger [?] project.

Same code but different result..........?

Postby kielsoft » May 30th, 2011, 1:34 am

Variable (C#: row / PHP: $row) is derived from DataTable NewRow(), which data are added to it successfully but in the real C# it data display well in DataGridView but in Phalanger the DataGridView shows only the text 'System:::Data:::DataRow' in the first column of each row, the code of the 2 languages are below.

Is this a bug or I am still getting something wrong?

table.Rows.Add(row); //This is working well.

$table->Rows->Add($row); // dont work well

//Pure C#  ***********************************************

private void MakeDataTableAndDisplay()
{
// Create new DataTable and DataSource objects.
DataTable table = new DataTable();

// Declare DataColumn and DataRow variables.
DataColumn column;
DataRow row;
DataView view;

// Create new DataColumn, set DataType, ColumnName and add to DataTable.
column = new DataColumn();
column.DataType = System.Type.GetType("System.Int32");
column.ColumnName = "id";
table.Columns.Add(column);

// Create second column.
column = new DataColumn();
column.DataType = Type.GetType("System.String");
column.ColumnName = "item";
table.Columns.Add(column);

// Create new DataRow objects and add to DataTable.
for(int i = 0; i < 10; i++)
{
row = table.NewRow();
row["id"] = i;
row["item"] = "item " + i.ToString();
table.Rows.Add(row);
}

// Create a DataView using the DataTable.
view = new DataView(table);

// Set a DataGrid control's DataSource to the DataView.
dataGrid1.DataSource = view;
}

//Phalanger PHP *****************************************

private function button1_Click(System:::Object $sender, System:::EventArgs $e) {
// Create new DataTable and DataSource objects.
$table = new DataTable();

// Create new DataColumn, set DataType, ColumnName and add to DataTable.
$column = new DataColumn();
$column->DataType = System:::Type::GetType("System.String");
$column->ColumnName = "id";
$table->Columns->Add($column);

// Create second column.
$column = new DataColumn();
$column->DataType = System:::Type::GetType("System.String");
$column->ColumnName = "item";
$table->Columns->Add($column);

// Create new DataRow objects and add to DataTable.
for ($i = 0; $i < 10; $i++)
{
$row = $table->NewRow();
$row["id"] = $i;
$row["item"] = "item " . $i;
$table->Rows->Add($row);
}

// Create a DataView using the DataTable.
$view = new DataView($table);

// Set a DataGrid control's DataSource to the DataView.
$this->dataGridView1->DataSource = $view;

}

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 14 guests

cron

User Control Panel

Login

Who is online

In total there are 14 users online :: 0 registered, 0 hidden and 14 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 14 guests