Welcome everyone. Multilingual drop-down menu added. English and Arabic languages have been added and are working properly. I want a datagrid to do the same thing using Resource.resx and I don't know the code.
What I have tried:
1 Imports System.Threading
2 Imports System.Globalization
3 Imports System
4 Imports System.Data
5 Imports System.Data.SqlClient
6 Imports System.Configuration
7 Imports System.Web
8 Imports System.Web.Configuration
9 Imports System.Web.Security
10 Imports System.Collections
11 Imports System.IO
12
13 Public Class BasePage
14 Inherits System.Web.UI.Page
15 Protected connStr = WebConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
16
17 Protected WithEvents lblout As System.Web.UI.WebControls.Label
18 Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
19 Protected WithEvents DataGrid2 As System.Web.UI.WebControls.DataGrid
20 Protected WithEvents lblUser As System.Web.UI.WebControls.Label
21 Protected WithEvents Label1 As System.Web.UI.WebControls.Label
22 Protected WithEvents Label2 As System.Web.UI.WebControls.Label
23 Protected WithEvents ddlLanguages As System.Web.UI.WebControls.DropDownList
24 Protected Connection = New SqlConnection(connStr)
25
26 Protected Overrides Sub InitializeCulture()
27 Dim language As String = "en-us"
28
29
30 If Request.UserLanguages IsNot Nothing Then
31
32 language = Request.UserLanguages(0)
33 End If
34
35
36 If Request.Form("__EVENTTARGET") IsNot Nothing AndAlso Request.Form("__EVENTTARGET").Contains("ddlLanguages") Then
37
38 language = Request.Form(Request.Form("__EVENTTARGET"))
39 End If
40
41
42 Thread.CurrentThread.CurrentCulture = New CultureInfo("AR-SA")
43 Thread.CurrentThread.CurrentUICulture = New CultureInfo(language)
44
45 End Sub
46 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
47
48 If Session.Contents("name") = "" Then
49 lblout.Visible = True
50 lblout.Text = "User Session Expired, please Login again...."
51 Else
52 lblout.Visible = False
53 lblUser.Text = Session.Contents("name")
54
55 BINDSEC()
56 BindTime()
57 End If
58 If Not Me.IsPostBack Then
59 If ddlLanguages.Items.FindByValue(CultureInfo.CurrentCulture.Name) IsNot Nothing Then
60 ddlLanguages.Items.FindByValue(CultureInfo.CurrentCulture.Name).Selected = True
61 End If
62 End If
63 End Sub
64 Dim ULOCATION, UCOUNTER, REPORTLOCATION
65 Sub BINDSEC()
66 Dim Connection As New SqlConnection(connStr)
67 Dim adapter As New SqlDataAdapter("SELECT location,Counter,REPORTLOCATION from [hrusers] where userid='" & Session.Contents("name") & "'", Connection)
68 Dim ds As New DataSet()
69 adapter.Fill(ds, "tran")
70 ULOCATION = ds.Tables("tran").Rows(0).Item("LOCATION")
71 UCOUNTER = ds.Tables("tran").Rows(0).Item("COUNTER")
72 REPORTLOCATION = ds.Tables("tran").Rows(0).Item("REPORTLOCATION")
73 End Sub
74 Sub BindTime()
75 Dim Connection As New SqlConnection(connStr)
76
77
78
79
80 Dim adapter4 As New SqlDataAdapter("SELECT MEALTYPE, CONVERT(varchar, STARTTIME) AS StartTime, CONVERT(varchar, ENDTIME) AS CloseTime,status,Mtype FROM A_MEALTIME WHERE Status='Y' and STARTTIME < GETDATE() AND ENDTIME > GETDATE() ", Connection)
81 Dim ds4 As New DataSet()
82 adapter4.Fill(ds4, "head4")
83 DataGrid2.DataSource = ds4.Tables("head4").DefaultView
84 DataGrid2.DataBind()
85 If ds4.Tables("head4").Rows.Count <> 0 Then
86 DataGrid2.Visible = True
87 Label1.Visible = True
88 Else
89 DataGrid2.Visible = False
90 Label1.Visible = False
91
92 End If
93
94 Dim adapter2 As New SqlDataAdapter("SELECT MEALTYPE, CONVERT(varchar, STARTTIME, 108) AS StartTime, CONVERT(varchar, ENDTIME, 108) AS CloseTime,Status,'Normal' as Type FROM MEALTIME WHERE Status='Y' AND REPORTLOCATION ='" & REPORTLOCATION & "' and (CONVERT(varchar, STARTTIME, 108) < CONVERT(varchar, GETDATE(), 108)) AND (CONVERT(varchar, ENDTIME, 108) > CONVERT(varchar, GETDATE(),108)) ", Connection)
95 Dim ds2 As New DataSet()
96 adapter2.Fill(ds2, "tran2")
97 DataGrid1.DataSource = ds2.Tables("tran2").DefaultView
98 DataGrid1.DataBind()
99
100
101
102 If ds2.Tables("tran2").Rows.Count <> 0 Then
103 DataGrid1.Visible = True
104 Label2.Visible = True
105 Else
106 DataGrid1.Visible = False
107 Label2.Visible = True
108 End If
109
110 End Sub
111
112 End Class