PDA

View Full Version : Các bro chỉ dẫn về Dropdownlist với



hienld88
26-02-2010, 14:53
Em làm trang Admin_new cho web 2 ngôn ngữ.Trong đó có một cái Dropdownlist để cho người dùng select Tiếng Anh hoặc Tiếng Việt.Vậy mình làm sao để khi select Tiếng Anh thì Add nó sẽ vào table New_en trên Database và Tiếng Viêt thì nó sẽ vào table New_vn.

[=========> Bổ sung bài viết <=========]

uppppppppppppppppppppppppppppp

[=========> Bổ sung bài viết <=========]

aaaaaaaaaaaaaaaaaaaaaaaaa

loading ...
26-02-2010, 15:28
bạn có thể tham khảo ví dụ này
http://quickstart.developerfusion.co.uk/QuickStart/aspnet/doc/ctrlref/standard/dropdownlist.aspx

hienld88
26-02-2010, 16:04
thank bạn nhưng ko phải là bài mình cần rồi

[=========> Bổ sung bài viết <=========]

có bro nào giúp vơisssss

thuyduongcd
27-02-2010, 09:40
bắt sự kiện onchange của tag select gọi tới 1 hàm, hàm này sẽ dùng wondow.location để redirect tới trang tương ứng
VD: window.location=http://domain/page.php?lang=en

Trong trang page.php dùng $_GET để xác định ngôn ngữ sẽ hiển thị mà chọn New_en hay New_vi

P.S: Thay vì tốn công gõ 1 loạt chữ a thì hãy nêu rõ ngôn ngữ mình đang dùng là gì sẽ tốt hơn

hienld88
01-03-2010, 10:00
thank bạn.Đúng là thiếu sót chỗ này.Mình làm ngôn ngữ C#,aspx.Ai vào chỉ dẫn với

[=========> Bổ sung bài viết <=========]

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Admin_AboutDNH : System.Web.UI.Page
{
string conStr = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
int id = 0;
SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
if ((string)Session["login"] != "ok")
{
Response.Redirect("Default.aspx");
}
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{

if (IsPostBack)
{
int chon = Convert.ToInt32(DropDownList1.SelectedValue.ToStri ng());
int count = 0;
string txt_des = TextBox1.Text.Trim();
string content = fck1.Value.Trim();
SqlConnection conn = new SqlConnection(conStr);
conn.Open();
SqlCommand cmd = new SqlCommand();
if (chon == 1)
{
cmd.CommandText = "EditAbout";
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@ab_id", SqlDbType.Int));
cmd.Parameters["@ab_id"].Value = id;
cmd.Parameters.Add(new SqlParameter("@ab_des", SqlDbType.NText));
cmd.Parameters["@ab_des"].Value = txt_des;
cmd.Parameters.Add(new SqlParameter("@ab_content", SqlDbType.NText));
cmd.Parameters["@ab_content"].Value = content;
count = cmd.ExecuteNonQuery();
conn.Close();
if (count != 0)
{
Label1.Visible = true;
}
else
{
Label1.Visible = false;
}
}
if (chon == 2)
{
cmd.CommandText = "EditAbout_en";
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@ab_id", SqlDbType.Int));
cmd.Parameters["@ab_id"].Value = id;
cmd.Parameters.Add(new SqlParameter("@ab_des", SqlDbType.NText));
cmd.Parameters["@ab_des"].Value = txt_des;
cmd.Parameters.Add(new SqlParameter("@ab_content", SqlDbType.NText));
cmd.Parameters["@ab_content"].Value = content;
count = cmd.ExecuteNonQuery();
conn.Close();
if (count != 0)
{
Label1.Visible = true;
}
else
{
Label1.Visible = false;
}
}

}
}

protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect("Center.aspx");
}
}

[=========> Bổ sung bài viết <=========]

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[EditAbout]
@ab_id int,
@ab_des ntext,
@ab_content ntext
AS
update Aboutus_vn
set ab_des=@ab_des, ab_content = @ab_content
where ab_id = @ab_id
RETURN

[=========> Bổ sung bài viết <=========]

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[EditAbout_en]
@ab_id int,
@ab_des ntext,
@ab_content ntext
AS
update Aboutus_en
set ab_des=@ab_des, ab_content = @ab_content
where ab_id = @ab_id
RETURN