M
Maksman
Well, I'm having trouble setting myDataGrid to show ordinal position of row
in a DataSource in the first column (...say, like Excel does)
Code snippet follows:
....
myDataSet.Clear();
myDataSet.EnforceConstraints = false;
myDataAdapter = new SqlDataAdapter(mySelectCommand);
myDataAdapter.Fill(myDataSet, "MyTable");
FillRowNumColumn();
....
private int FillRowNumColumn() // Ver 1
{
int rowNum = 0;
foreach(MyDataRow myRow in myDataSet.MyTable)
{
myRow.rowNum = ++rowNum;
}
return rowNum;
}
private int FillRowNumColumn() // Ver 2
{
for(int rowNum = 1; rowNum <= MyTable.Rows.Count; ++rowNum)
{
myDataGrid[rowNum-1, 0] = rowNum;
}
return rowNum;
}
....
This does the job but performance dramatically decreases when dataTable
contains large amount of records (10.000 and more)
1. Is there a way to set the rowNum value without an extra 'FillRowNum'
method
2. How to add a column to DataGrid which displays just a line number of row.
Thanks
Maks
in a DataSource in the first column (...say, like Excel does)
Code snippet follows:
....
myDataSet.Clear();
myDataSet.EnforceConstraints = false;
myDataAdapter = new SqlDataAdapter(mySelectCommand);
myDataAdapter.Fill(myDataSet, "MyTable");
FillRowNumColumn();
....
private int FillRowNumColumn() // Ver 1
{
int rowNum = 0;
foreach(MyDataRow myRow in myDataSet.MyTable)
{
myRow.rowNum = ++rowNum;
}
return rowNum;
}
private int FillRowNumColumn() // Ver 2
{
for(int rowNum = 1; rowNum <= MyTable.Rows.Count; ++rowNum)
{
myDataGrid[rowNum-1, 0] = rowNum;
}
return rowNum;
}
....
This does the job but performance dramatically decreases when dataTable
contains large amount of records (10.000 and more)
1. Is there a way to set the rowNum value without an extra 'FillRowNum'
method
2. How to add a column to DataGrid which displays just a line number of row.
Thanks
Maks