Monday, June 1, 2009

Add English and Khmer value to ComboBox

protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack) {
//--- Add TrainerId, TrainerName to Combox
addTrainer();
}
}
---------------------------------------
void addTrainer(){
DBAccess db = new DBAccess();
DataSet ds = new DataSet();
ds = db.ExecuteDataSet("SELECT TrainerID, TrainerNameEng, TrainerNameKh, CASE WHEN TrainerNameEng IS NULL THEN TrainerNameKh WHEN TrainerNameKh IS NULL THEN TrainerNameEng ELSE TrainerNameEng + space(3) + TrainerNameKh END AS Display FROM dbo.tblTrainer");
this.ddlTrainerName.DataSource = ds.Tables[0];
this.ddlTrainerName.DataTextField = "Display";
this.ddlTrainerName.DataValueField = "TrainerID";
this.DataBind();
}

No comments: