ここでは初心者なので、潜在的なパフォーマンスの問題とは何か、ベスト プラクティスとは何かがわかりません。
これは良い考えですか?考え?
これから:(セルコードがいたるところにある場合、および/またはグリッドビューが変更された場合、手動エラーが発生しやすくなります)
row.Cells[1].Visible = false; // CustomerId
row.Cells[9].Visible = false; // OrderNumber
row.Cells[10].Visible = false; // ProductId
. . .
int matchId = row.Cells[11].Text;
. . .
これに:(より読みやすく管理しやすい、列挙型がグリッドビューと同期していることを確認してください)
row.Cells[Col.CustomerId.GetVal()].Visible = false;
row.Cells[Col.OrderNumber.GetVal()].Visible = false;
row.Cells[Col.ProductNumber.GetVal()].Visible = false;
. . .
int matchId = row.Cells[Col.CustomerName.GetVal()].Text;
. . .
public enum Col
{
MatchId = 1,
. . .
ServiceCode = 9,
CustomerId = 10,
CustomerName = 11,
. . .
}
public static class ColExt
{
static public int GetVal(this Col col)
{
return (int)col;
}
}