<div> <asp:DropDownList ID="ddlAdmin" runat="server" > <table width="70%"> <tr><td colspan="3"> <asp:ListBox ID="ProductListBox" runat="server" SelectionMode="Multiple" ></td> <td><asp:Button ID="BtnMoveLeft" runat="server" Text="Add Permission" OnClick="BtnMoveleft_Click" /></td> <td> <asp:ListBox ID="PermissionListBox" runat="server" SelectionMode="Multiple" ></td> </tr> </table> </div>
protected void Page_Load(object sender, EventArgs e) { FillProductList(); FillAdminDropDownList(); } protected void FillAdminDropDownList() { DataManager myData = new DataManager(DbFunctions.GetConnectionString()); MySqlConnection myPConn = myData.GetPooledConnection(new MySqlConnection()); MySqlCommand cmd = new MySqlCommand("SELECT adminuserid,adminusername FROM adminusermast", myPConn); DataTable dt = new DataTable(); myPConn.Open(); MySqlDataAdapter adptr = new MySqlDataAdapter(cmd); adptr.Fill(dt); myPConn.Close(); if (dt.Rows.Count > 0) { ddlAdmin.Items.Clear(); ddlAdmin.Items.Add("SELECT"); foreach (DataRow drow in dt.Rows) { ListItem lst = new ListItem(); lst.Value = drow[1].ToString(); lst.Text = drow[0].ToString(); ddlAdmin.Items.Add(lst); } } } protected void FillProductList() { DataManager myData = new DataManager(DbFunctions.GetConnectionString()); MySqlConnection myPConn = myData.GetPooledConnection(new MySqlConnection()); MySqlCommand com = new MySqlCommand("Select productid,productname from productmast", myPConn); MySqlDataReader Reader = null; myPConn.Open(); Reader = com.ExecuteReader(); while (Reader.Read()) { ListItem newItem = new ListItem(); newItem.Text = Reader["productname"].ToString(); newItem.Value = Reader["productid"].ToString(); ProductListBox.Items.Add(newItem); } Reader.Close(); myPConn.Close(); } protected void BtnMoveleft_Click(object sender, EventArgs e) { for (int i = ProductListBox.Items.Count - 1; i >= 0; i--) { if (ProductListBox.Items[i].Selected == true) { PermissionListBox.Items.Add(ProductListBox.Items[i]); ListItem li = ProductListBox.Items[i]; ProductListBox.Items.Remove(li); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)