Try:
string template = myRichTextBox.Text;
foreach (DataGridViewRow row in myDataGridView2.Rows)
{
string demand = template;
object stdName = row.Cells["stdName"].Value;
object message = row.Cells["Message"].Value;
if (!string.IsNullOrWhiteSpace(demand) && stdName != null && message != null)
{
demand = demand.Replace("&&", stdName.ToString());
demand = demand.Replace("$$", message.ToString());
row.Cells["demand"].Value = demand;
}
}