-->

Save and fetch data into/from sql server database in other language (hindi, bengali, english, marathi, malayalam etc) using ASP.NET C#.

Introduction

In this post, I am implementing Save and fetch data into/from sql server database in other language (hindi, bengali, english, marathi, malayalam etc) using ASP.NET C#.

Steps :

Step - 1: Create New Project.

Go to File > New > Project > Select asp.net web forms application > Entry Application Name > Click OK.

Step-2: Add a Database.

Go to Solution Explorer > Right Click on App_Data folder > Add > New item > Select SQL Server Database Under Data > Enter Database name > Add.

Step-3: Create table for Save/fetch different languages(hindi, english, bengali, marathi etc.) data.

Open Database > Right Click on Table > Add New Table > Add Columns > Save > Enter table name > Ok.
In this example, I have used one tables as below

Step-4: Add Entity Data Model.

Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > New item > Select ADO.net Entity Data Model under data > Enter model name > Add.
A popup window will come (Entity Data Model Wizard) > Select Generate from database > Next >
Chose your data connection > select your database > next > Select tables > enter Model Namespace > Finish.

Step-5: Add a Webpage and Design for Save / Display different languages(hindi, english, bengali, marathi etc.).

Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > New item > Select web form/ web form using master page under Web > Enter page name > Add.

HTML Code
  1. <h3>How to save and fetch data into/from sql server database in other language(hindi, bengali, malayalam etc)</h3>
  2. <table>
  3. <tr>
  4. <td>Type in Hindi : </td>
  5. <td>
  6. <asp:TextBox ID="txtHindiContent" runat="server" ClientIDMode="Static" TextMode="MultiLine" Height="100" Width="250"></asp:TextBox>
  7. </td>
  8. </tr>
  9. <tr>
  10. <td>
  11. </td>
  12. <td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
  13. </tr>
  14. <tr>
  15. <td colspan="2" align="center">
  16. <asp:Label ID="lblMessage" runat="server" />
  17. </td>
  18. </tr>
  19. </table>
  20. <div>
  21.  
  22. <asp:GridView ID="gvContent" runat="server" AutoGenerateColumns="false">
  23. <Columns>
  24. <asp:BoundField HeaderText="Sl No" DataField="SLID" />
  25. <asp:BoundField HeaderText="Content" DataField="HindiContent" />
  26. </Columns>
  27. </asp:GridView>
  28. </div>
JS Code
Here in place of YourKeyHere Enter your Google API Key. How to get Google API Key?

  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  2. <script type="text/javascript" src="https://www.google.com/jsapi?key=YourKeyHere">
  3. </script>
  4. <script language="javascript" type="text/javascript">
  5. google.load("elements", "1", {
  6. packages: "transliteration"
  7. });
  8.  
  9. function onLoad() {
  10. var options = {
  11. sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
  12. destinationLanguage: google.elements.transliteration.LanguageCode.HINDI, // available option English, Bengali, Marathi, Malayalam etc.
  13. shortcutKey: 'ctrl+g',
  14. transliterationEnabled: true
  15. };
  16.  
  17. var control = new google.elements.transliteration.TransliterationControl(options);
  18. control.makeTransliteratable(['txtHindiContent']);
  19. }
  20. google.setOnLoadCallback(onLoad);
  21.  
  22. </script>

Step-6: Write this into page_load event for fetch different languages(hindi, english, bengali, marathi etc.) data from database and show in Page .


  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. if (!IsPostBack)
  4. {
  5. PopulateContent();
  6. }
  7. }
Write this function into your page behind. and here is the function...
  1. private void PopulateContent()
  2. {
  3. using (MyDatabaseEntities dc = new MyDatabaseEntities())
  4. {
  5. gvContent.DataSource = dc.ContentTables.ToList();
  6. gvContent.DataBind();
  7. }
  8. }

Step-7: Write this into Button Click event for Save different languages(hindi, english, bengali, marathi etc.) data into database.


  1. protected void btnSave_Click(object sender, EventArgs e)
  2. {
  3. if (!string.IsNullOrEmpty(txtHindiContent.Text.Trim()))
  4. {
  5. using (MyDatabaseEntities dc = new MyDatabaseEntities())
  6. {
  7. dc.ContentTables.Add(new ContentTable
  8. {
  9. SLID = 0,
  10. HindiContent= txtHindiContent.Text.Trim()
  11. });
  12. dc.SaveChanges();
  13. lblMessage.Text = "Successfully saved!";
  14. }
  15. PopulateContent();
  16. }
  17. }

Step-8: Run Application. 




Related post:


Hello ! My name is Sourav Mondal. I am a software developer working in Microsoft .NET technologies since 2010.

I like to share my working experience, research and knowledge through my site.

I love developing applications in Microsoft Technologies including Asp.Net webforms, mvc, winforms, c#.net, sql server, entity framework, Ajax, Jquery, web api, web service and more.

Related Posts: