using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication14
{
public partial class Test_lang : System.Web.UI.Page
{
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection();
string connection = System.Configuration.ConfigurationManager.AppSettings["con"].ToString();
IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
19 Points
84 Posts
I want to save and retrieve data to sql in hindi language from asp.net webpage
Jun 08, 2020 09:11 AM|sanam13|LINK
Hlo Professionals!
Here is my code
Html Code
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Test lang.aspx.cs" Inherits="WebApplication14.Test_lang" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="body" runat="server">
<div style="margin-top:30px; margin-left:20px">
<h1><strong style="color:black">Test Language</strong></h1>
<hr />
<table>
<tr>
<td><span style="color:black">First Name</span><br />
<asp:TextBox ID ="tb_name" runat="server" Width="200px" /><br />
</td>
<td><span style="margin-left:25px; color:black">Last Name<br /></span>
<span style="margin-left:25px"><asp:TextBox ID="tb_last" runat="server" Width="200px" /></span> <br />
</td>
</tr>
<tr>
<td><br />
<asp:Button ID="BT_submit" runat="server" Text="Submit" style="border-radius:5px" Height="35px" Width="80px" OnClick="BT_submit_Click" BackColor="#3366CC" BorderColor="#3366CC" ForeColor="White" /></td>
</tr>
</table>
</div>
<div>
<asp:GridView runat="server" AutoGenerateColumns="false" ID="Gv1" Width="100%" >
<Columns>
<asp:BoundField DataField ="first_name" HeaderText ="First Name" />
<asp:BoundField DataField ="last_Name" HeaderText ="Last Name" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
</asp:Content>
C# Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace WebApplication14
{
public partial class Test_lang : System.Web.UI.Page
{
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection();
string connection = System.Configuration.ConfigurationManager.AppSettings["con"].ToString();
public void EstablishConnection(string storeprocedure)
{
con.ConnectionString = connection;
cmd.Connection = con;
cmd.Connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = storeprocedure;
}
public void CloseConnection()
{
cmd.Connection.Close();
cmd.Connection.Dispose();
con.Close();
}
public void FillGridview()
{
SqlDataAdapter adp = new SqlDataAdapter("select * from test_hp", connection);
adp.SelectCommand.CommandType = CommandType.Text;
DataTable DT = new DataTable();
adp.Fill(DT);
Gv1.DataSource = DT;
Gv1.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
}
protected void BT_submit_Click(object sender, EventArgs e)
{
EstablishConnection("sp_insert_test_hp");
cmd.Parameters.Add("@first_name", SqlDbType.VarChar, 100).Value = tb_name.Text;
cmd.Parameters.Add("@last_name", SqlDbType.VarChar, 100).Value = tb_last.Text;
cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 100).Value = "1";
cmd.Parameters.Add("@date_time", SqlDbType.VarChar, 100).Value = System.DateTime.Now.ToString();
cmd.Parameters.Add("@Status", SqlDbType.VarChar, 100).Value = "1";
cmd.Parameters.Add("@By_whom", SqlDbType.VarChar, 100).Value = Session["username"].ToString();
try { cmd.ExecuteNonQuery(); }
catch (Exception ex1) { Response.Write("<script language=javascript>alert('" + ex1.Message.ToString() + ".')</script>"); }
CloseConnection();
FillGridview();
}
}
}
Contributor
3370 Points
1409 Posts
Re: I want to save and retrieve data to sql in hindi language from asp.net webpage
Jun 08, 2020 10:04 AM|samwu|LINK
Hi sanam13,
Do you want to convert other languages to hindi? if so, you can try this demo:
More information about how to set the language you can refer to this video:
https://www.youtube.com/watch?v=TV9U7Adoj_o
Best regards,
Sam