C# Web アプリケーションに GridView コントロールがあります。私のグリッドビューには、 Select という ButtonField がありID="btnSelect"ます。基本的に、私の GridView コントロールには、クライアントの名、姓、住所、電話番号があり、対応する情報にはテキスト ボックスがあります。グリッドビューで選択ボタンを押す/起動すると、クライアント名をテキスト ボックスに入力したいのですが、それは成功しましたが、私のアプリケーションでは最大 6 つのクライアントを選択できます。私がこれを行っている方法よりも良い方法はありますか? コードは以下のとおりです。
 void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
 {
  int index = Convert.ToInt32(e.CommandArgument);
  GridViewRow row = GridView1.Rows[index];
  if(string.IsNullOrEmpty(txtName1.Text) && string.IsNullOrEmpty(txtLName1.Text) &&
     string.IsNullOrEmpty(txtAddr1.Text) && string.IsNullOrEmpty(txtPhone1.Text))
    {
      txtName1.Text=Server.HtmlDecode(row.Cells[1].Text);
      txtLName1.Text=Server.HtmlDecode(row.Cells[2].Text);
      txtAddr1.Text=Server.HtmlDecode(row.Cells[3].Text);
      txtPhone1.Text=Server.HtmlDecode(row.Cells[4].Text);
    }
  //If I hit another select button then this will load the sencond set of txtboxes
    if(string.IsNullOrEmpty(txtName2.Text) && string.IsNullOrEmpty(txtLName2.Text) &&
     string.IsNullOrEmpty(txtAddr2.Text) && string.IsNullOrEmpty(txtPhone2.Text))
    {
      txtName2.Text=Server.HtmlDecode(row.Cells[1].Text);
      txtLName2.Text=Server.HtmlDecode(row.Cells[2].Text);
      txtAddr2.Text=Server.HtmlDecode(row.Cells[3].Text);
      txtPhone2.Text=Server.HtmlDecode(row.Cells[4].Text);
    }
 //The thrid time will load the third button and so on until I fill each txtbox if I choose.
}
コマンド行の [選択] ボタンを押すたびに、複雑な if ステートメントをすべて配置する必要がなくなるように、これをコーディングするより良い方法はありますか? これを処理できる foreach ループのようなものはありますか?