Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
There is one DataGridView. It has three columns (stdName, Demand, Msg)

Now I want to replace the stdName with "&&" and Demand with "$$" where it is presenting in the sentence.

I have one RichtextBox. It is holding a sentence i.e. Dear Parents, Your ward && fee Rs. "$$" has not been deposited.

Gridview
===========================================
stdName | Message | Demand
===========================================
Rahul | 500 |
Sonu | 450 |
Monu | 600 |
=============================================

After replacement it should show in demand column
================================================================================
Demand
================================================================================
Dear Parents, Your ward Rahul fee Rs. 500 has not been deposited.
Dear Parents, Your ward Sonu fee Rs. 450 has not been deposited.
Dear Parents, Your ward Monu fee Rs. 600 has not been deposited.
========================================================================

What I have tried:

..............................................
Posted
Updated 25-Oct-16 22:38pm
v2

1 solution

Try:
C#
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;
        }
    }
 
Share this answer
 
Comments
nityanand NCR 5-Nov-16 2:04am    
Sir could you help??
Plase see this link

http://www.codeproject.com/Answers/1152303/Transactional-status-through-SQL-querry#answer1

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900