-->

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
     <h3>How to save and fetch data into/from sql server database in other language(hindi, bengali, malayalam etc)</h3>
    <table>
        <tr>
            <td>Type in Hindi : </td>
            <td>
                <asp:TextBox ID="txtHindiContent" runat="server" ClientIDMode="Static" TextMode="MultiLine" Height="100" Width="250"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td>
                </td>
            <td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <asp:Label ID="lblMessage" runat="server" />
            </td>
        </tr>
    </table>
    <div>

        <asp:GridView ID="gvContent" runat="server" AutoGenerateColumns="false">
            <Columns>
                <asp:BoundField HeaderText="Sl No" DataField="SLID" />
                <asp:BoundField HeaderText="Content" DataField="HindiContent" />
            </Columns>
        </asp:GridView>
    </div>
        
JS Code
Here in place of YourKeyHere Enter your Google API Key. How to get Google API Key?

     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="https://www.google.com/jsapi?key=YourKeyHere">
    </script>
    <script language="javascript" type="text/javascript">
        google.load("elements", "1", {
            packages: "transliteration"
        });

        function onLoad() {
            var options = {
                sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
                destinationLanguage: google.elements.transliteration.LanguageCode.HINDI, // available option English, Bengali, Marathi, Malayalam etc.
                shortcutKey: 'ctrl+g',
                transliterationEnabled: true
            };

            var control = new google.elements.transliteration.TransliterationControl(options);
            control.makeTransliteratable(['txtHindiContent']);
        }
        google.setOnLoadCallback(onLoad);

    </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 .


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

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


            
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtHindiContent.Text.Trim()))
            {
                using (MyDatabaseEntities dc = new MyDatabaseEntities())
                {
                    dc.ContentTables.Add(new ContentTable
                    {
                         SLID = 0,
                         HindiContent= txtHindiContent.Text.Trim()
                    });
                    dc.SaveChanges();
                    lblMessage.Text = "Successfully saved!";
                }
                PopulateContent();
            }
        }
        

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.