/// <summary> /// Method Name:objDdlCreate_SelectedIndexChanged /// Decsription:Show the Selected Item on label /// Author:Bhumi /// Created On:18/6/2015 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void objDdlCreate_SelectedIndexChanged(object sender, EventArgs e) { try { for (int i = 0; i < TblDynamic.Rows.Count; i++) { DropDownList Ddl = (DropDownList)sender; //Identify Dropdownlist from table if (TblDynamic.Rows[i].Cells[0].Controls.Contains((DropDownList)Ddl)) { objconstant = new ConstantMessage(); //Derive label from table and show Label Message TblDynamic.Rows[i].Cells[1].Text = objconstant.strselectedvalue + Ddl.SelectedItem; } } } catch (Exception) { objconstant = new ConstantMessage(); Response.Redirect(objconstant.strerrorpage);//Error } finally { objconstant = null; LblText = null; objDdlCreate = null; //TxtItem.Text = "";For second dropdownlist event textbox value find blank } }
/// <summary> /// Method Name:BtnLeftToRight_Click /// Description: Move the Data from ListBox1 to ListBox2 /// Author:Bhumi /// Created On:17/6/2015 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnLeftToRight_Click(object sender, EventArgs e) { List <ListItem> Selected_Items; try { if (LstItem1.Items.Count > 0) { if (LstItem1.SelectedIndex != -1) { Selected_Items = new List <ListItem>(); foreach (ListItem item in LstItem1.Items) { if (item.Selected) { Selected_Items.Add(item); } } foreach (ListItem item in Selected_Items) { LstItem2.Items.Add(item); LstItem1.Items.Remove(item); } objconstant = new ConstantMessage(); ClientScript.RegisterStartupScript(this.GetType(), "msgbox", "alert('" + objconstant.stritemshift + "');", true); } else { //Index Not Selected objconstant = new ConstantMessage(); ClientScript.RegisterStartupScript(this.GetType(), "msgbox", "alert('" + objconstant.stralertitem1notselected + "');", true); } } else { //Empty ListBox objconstant = new ConstantMessage(); ClientScript.RegisterStartupScript(this.GetType(), "msgbox", "alert('" + objconstant.stralertEmptyListbox1 + "');", true); } } catch (Exception) { objconstant = new ConstantMessage(); Response.Redirect(objconstant.strerrorpage); } finally { objconstant = null; Selected_Items = null; LstItem1.ClearSelection(); LstItem2.ClearSelection(); } }
/// <summary> /// Method Name:Dynamic_Table_Fill /// Description:Dynamically Generate Table & Table Rows with Dropdownlist and Labels /// Author:Bhumi /// Created On:17/6/2015 /// </summary> public void Dynamic_Table_Fill() { Array.Sort(objArray);//Sort the Array TableRow tRow; TableCell tCell; try { if (TxtItem.Text != "") { for (int i = 1; i <= objArray.Length; i++) { // Create new row and add it to the table. tRow = new TableRow(); TblDynamic.Rows.Add(tRow); for (int j = 1; j < 2; j++) { tCell = new TableCell(); tRow.Cells.Add(tCell);//ADD Cell objDdlCreate = new DropDownList(); objDdlCreate.AutoPostBack = true; objDdlCreate.DataSource = objArray; objDdlCreate.DataBind(); objDdlCreate.SelectedIndexChanged += objDdlCreate_SelectedIndexChanged; tCell.Controls.Add(objDdlCreate); //Add Dropdownlist In Cell tCell = new TableCell(); tRow.Cells.Add(tCell); //ADD Cell LblText = new Label(); tCell.Controls.Add(LblText); //Add Label in cell } } } else { objconstant = new ConstantMessage(); ClientScript.RegisterStartupScript(this.GetType(), "msgbox", "alert('" + objconstant.strblankItem + "');", true); } } catch (Exception) { objconstant = new ConstantMessage(); Response.Redirect(objconstant.strerrorpage);//Error } finally { objDdlCreate = null; tRow = null; tCell = null; objconstant = null; } }
/// <summary> /// Method Name:BtnAddlist_Click /// Description: ADD the Items From TextBox to ListBox1 /// Author:Bhumi /// Created On:17/6/2015 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnAddlist_Click(object sender, EventArgs e) { //Add the value of Textbox in ListBox1 if ((TxtItem.Text).Trim() != "") { LstItem1.Items.Add(((TextBox)TxtItem).Text); TxtItem.Text = ""; LblInsert.Visible = true; } else { objconstant = new ConstantMessage(); ClientScript.RegisterStartupScript(this.GetType(), "msgbox", "alert('" + objconstant.strblankItem + "');", true); } }
protected void Page_Load(object sender, EventArgs e) { objconstant = new ConstantMessage(); Response.Write(objconstant.strerrormessage); }