Click here to Skip to main content
14,970,700 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have one RichtextBox. It is holding a sentence i.e. Dear Parents, Your ward $$ has not come to school today.

One Gridview control is also available on the same form and it is containing 3 Columns which is SrNo., Student'sName & Message.

Now I want to replace the Student'sName with double dollar where it is presenting in the sentence.

My Gridview is like
===========================================
SrNo. Student'sName Message
===========================================
1- Name-1 Null
2- Name-2 Null
3- Name-3 Null
=============================================

After replacement it should show lik e
====================================================================================
Sr.No. Student'sName Message
====================================================================================
1- Name-1 Dear Parents, Your ward Name-1 has not come to school today.
2- Name-2 Dear Parents, Your ward Name-2 has not come to school today.
3- Name-3 Dear Parents, Your ward Name-3 has not come to school today.
====================================================================================

Please helm me.

Thanks

What I have tried:

........................................
Posted
Updated 15-Jul-16 21:01pm
v2

1 solution

try this


C#
private void button1_Click(object sender, EventArgs e)
      {
          string text = richTextBox1.Text; //"Dear Parents, Your ward $$ has not come to school today.";
          foreach (DataGridViewRow row in dataGridView1.Rows)
          {
              string name = Convert.ToString(row.Cells[1].Value);
              if (!string.IsNullOrWhiteSpace(name))
                  row.Cells[2].Value = text.Replace("$$", name);

          }

      }
   
Comments
Member 12245539 16-Jul-16 3:11am
   
Mr. Karthik could you tell me one more question?
How I can generate SQL Database script with its all table values through C# programming??
Karthik_Mahalingam 16-Jul-16 3:15am
   
Hi,
if it related this question you can ask in the comments section, else you shall ask a new question so that who is aware of that will reply to that immediately.
so if this question is resolved, please close this post and ask a new question on that by providing more details.

"How I can generate SQL Database script with its all table values through C# programming??"
you can achieve this in many ways, try google, if no luck then post a question.

Thanks
karthik
Member 12245539 16-Jul-16 3:25am
   
ok
thanks
Karthik_Mahalingam 16-Jul-16 3:27am
   
is this working?

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