Web Forms :: How To Copy Multiple Item From ListBox1 To ListBox2

Dec 20, 2010

i want to know how to copy multiple items from Listbox1 to Listbox2.i tried in single item copy it's working but i want to know multiple items to copy.

here is my code..

.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 65%;
height: 261px;
}
.style2
{
width: 64px;
}
.style3
{
width: 46px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td rowspan="4">
<asp:ListBox ID="lstLeft" runat="server" AppendDataBoundItems="True"
Height="285px" SelectionMode="Multiple" Width="213px">
<asp:ListItem>10th</asp:ListItem>
<asp:ListItem>Diploma</asp:ListItem>
<asp:ListItem>12th</asp:ListItem>
<asp:ListItem>UG</asp:ListItem>
<asp:ListItem>PG</asp:ListItem>
</asp:ListBox>
</td>
<td>
</td>
<td rowspan="4">
<asp:ListBox ID="lstRight" runat="server" Height="286px"
SelectionMode="Multiple" Width="213px"></asp:ListBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="butAdd" runat="server" onclick="butAdd_Click" Text="-->"
Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="butRemove" runat="server" onclick="butRemove_Click"
Text="<--" Width="63px" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<html
aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
ListItem Item = new ListItem();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void butAdd_Click(object sender, EventArgs e)
{
if (lstLeft.SelectedIndex > -1)
{
if (lstRight.Items.FindByValue(lstLeft.SelectedItem.Text) == null)
{
Item.Text = lstLeft.SelectedItem.Value;
Item.Value = lstLeft.SelectedItem.Text;
lstRight.Items.Add(Item);
lstLeft.Items.Remove(lstLeft.SelectedItem);
}
}
}
protected void butRemove_Click(object sender, EventArgs e)
{
if (lstRight.SelectedIndex > -1)
{
Item.Text = lstRight.SelectedItem.Value;
Item.Value = lstRight.SelectedItem.Text;
lstLeft.Items.Add(Item);
lstRight.Items.Remove(lstRight.SelectedItem);
}
}
}

View 1 Replies


Similar Messages:

Web Forms :: How To Add Listbox1 Items To Listbox2

Sep 3, 2010

I have 2 listboxes,if i select listbox1 items ,it has to be displayed in listbox2 without duplicate values.

for example if i select item "usa" in listbox1 it has to be added in listbox2.

Aagain if i select " usa" it should not add to listbox2.

one more point is i dont want to delete items from listbox1 once i select.

View 2 Replies

Move DataTextField & DataValueField From Listbox1 To Listbox2?

Jul 9, 2010

I have 2 listboxes....

Listbox1 has

DataTextField="Category"
DataValueField="CategoryID"
(coming from Dropdownlist)

I want to move a Item (a Category) from listbox1 to listbox2...but how do I move this Category Plus the CategoryID to lisbox2 (CategoryID should not be visible but still be associated with Category in Listbox2)

So I want the newly added Categories to be visible in Listbox2 ..but their CategoryID's must be invisible...but still be associated with their Category....

and when I save these Categories from Listbox2 to the Database.....its should be the CategoryID's that should go into the Database.....not the actual Category

So to explain again in a different way

I want to Move a selected DataTextField & its DataValueField from Listbox1 to listbox2

then only the array of DataValueField must be saved to Database

View 3 Replies

JQuery :: Moving Items From ListBox1 To ListBox2?

Oct 15, 2010

I have two ListBoxes.I want to movie items from ListBox1 to Listbox2 using jquery.

I want to save ListBox2 items in Xml file.

But i am unable to get ListBox2 items after moving from ListBox2.

I searched for this problem.Solutions is Use HiddenField for getting server side.

I am new to Dot net.So Explain with one simple example.

View 4 Replies

Web Forms :: Storing ListBox2 Values In XML File Using Jquery

Oct 20, 2010

I have 2 ListBoxes..ie ListBox1 and ListBox2.When Move items from ListBox1 to ListBox2,I want to save listBox2 values in Xml Files.When i open the page it will load lListBox2 values.

View 1 Replies

MVC :: Listbox1.selectedindex=0 Make The Same?

Jan 22, 2011

tis is in my cntroller class

var query3 = db.Machine_Bom.Select(c => new { c.Id, c.Machine_Name });
ViewData["Category"] = new SelectList(query3.AsEnumerable(), "Id", "Machine_Name");

in design

<%=Html.ListBox("emp", (SelectList)ViewData["Categories"], new { onchange = "addItem();", style = "width: 155px; height: 35px;" })%>

how to make the first item selected........in webforms i use listbox1.selectedindex=0 in load event but how to go with mvc

View 6 Replies

SQL Server :: Copy Data From Multiple Columns Into One Column?

Aug 26, 2010

My View has four columns with years, none of the rows have complete yearly data.

Current View

Columns 1-10, FY, Expr1, Expr2, Expr3
Some data, 2010 NULL,NULL, NULL
Some data, NULL, 2010, NULL, NULL
Some data, NULL, NULL, 2010, NULL
Some data, NULL, 2010, 2010, 2010
Some data, 2010, NULL, 2010, 2010,
Some data, NULL, NULL, 2010, NULL
Some data, 2010, 2010, NULL, 2010
Some data, NULL, NULL, NULL, 2010

A new column needs to relfect 2010 for each row in the View.

Goal New View
Columns 1-10, FY_NEW
Some data, 2010
Some data, 2010
Some data, 2010, etc. for each row in the view

I can not hard code the data as time moves forward next year rows will have 2012, etc.

How can I get lthe year, in this case 2010, into a new column regardless of the year?

View 10 Replies

AJAX :: How To Stop The SelectedIndexChanged Event For Listbox1 In UpdatePanel1 From Firing

Jun 15, 2010

Overview

I have 3 update panels on a page, each of them have UpdateMode="Conditional".

UpdatePanel1 contains listbox1 (AutoPostBack set to true) which is populated on pageinit from the DB.

UpdatePanel2 contains listbox2 (AutoPostBack set to true), this panel has AsyncPostBackTrigger set to the SelectedIndexChanged event for listbox1 in UpdatePanel1.

UpdatePanel3 contains textboxes that will hold the details once an item has been selected from listbox1 and listbox2, this panel has an AsyncPostBackTrigger set to the SelectedIndexChanged event for listbox2 in UpdatePanel2.

In the codebehind, the SelectedIndexChanged event for listbox1 populates listbox2 and the SelectedIndexChanged event for listbox2 populates the textboxes in UpdatePanel3.

The problem

When the page loads listbox1 is correctly populated, I select a value from listbox1 and listbox2 is populated, great, no problem so far. When I then select a value from listbox2 the SelectedIndexChanged event for listbox1 is firing, I assume that as this populates listbox2 again it is clearing the selected value for listbox2 as the SelectedIndexChanged event for listbox2 is not firing.

How do I stop the SelectedIndexChanged event for listbox1 in UpdatePanel1 from firing when I select a value from listbox2 in UpdatePanel2 ?

View 5 Replies

Data Controls :: Copy One File To Multiple Folder Of Remote Location By One Action

Apr 27, 2016

If I have one file- name (picnew.jpg) and want to paste it to six ip's d:

Few folder drive by one action.

asp.net or cmd commands or anything else

View 1 Replies

Web Forms :: Multiple Checkbox - Retrieve The Values Of Each Item That Is Checked

Dec 8, 2010

I am using a Checkboxlist and want to retrieve the values of each item that is checked.

[Code]....

This is only returning the first value selected: Label1.Text = this.chkCommunicate.Text;

View 10 Replies

Forms Data Controls :: How To Save Multiple Selections For One 1 Item?

Feb 20, 2011

I'm storing details about clothing in a database, and I need to save multiple entries for colour. For example, a user selects a top, and then needs to select the colours red, black, white and blue from say a group of tick boxes. How should I store this infomation, and what web controls would I use to help the user make there selection?

View 10 Replies

Forms Data Controls :: Prevent Multiple Submits With A Dataview Item Updating?

Dec 14, 2010

I have a button in my dataview that drives the update:

<asp:Button ID="btnUpdate" runat="server" Text="Submit Bid" CommandName="Update"

View 6 Replies

Forms Data Controls :: Displaying Multiple Values In A Control In Item Template Field?

Aug 5, 2010

I have a doubt regarding displaying data in gridview. I have comma separated values in a particular field in my database. Will I be able to display the comma separated values from db table in a control in the Item template field of my gridview?

View 2 Replies

How To Add A String To Array With Multiple Item

Apr 7, 2010

I got an array:

[Code]....

In arrHeader, I wanted to add a string value from arrRemark(1), with seperator ",". How can I do that?

View 6 Replies

C# - Add Multiple Commands To One Item Template?

Feb 9, 2011

I stripped this example to make it simple. I have a gridview with a template field. The template field contains two buttons and a label (They must be in the same template field). I want the first button to set the label text to "Win", and the other button to set the label text to "fail". The onrowcommand doesnt seem to be triggered by buttons in a template field. How can I accomplish this?

My gridview code is below:

<asp:GridView ID="GridView1" runat="server" EnableModelValidation="True" AutoGenerateColumns="False"
OnRowCommand="Gridview1_RowCommand">
<Columns>
<asp:TemplateField ShowHeader="False">

[Code]....

View 2 Replies

Multiple Group Item Display?

Apr 19, 2010

Given some rows of records as follows:1) 5 Continent headers2) Country subheader grouped under each continent3) City items (with links to individual city pages) displayed under each Country subgroupWhat would be the best control used to display the above data. Would a report viewer be good?

View 1 Replies

Set Scroll Bar To Selected Item In Multiple Select Listbox

Feb 1, 2010

I have a multiple select Listbox.When I click on it then it post backs and scroll back to the top of the Listbox. Is there any property to prevent it?

View 1 Replies

C# - Iterate Through Repeater Items To Set Only One Item As Default And Not Multiple?

Nov 18, 2010

There's this repeater...

<asp:Repeater ID="myRepeater" OnItemCommand="rpt1_ItemCommand" runat="server" OnItemDataBound="rpt1_OnItemDataBound">
<HeaderTemplate>
<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr class="lgrey">
<td>Default</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td>
<asp:LinkButton ID="lnk1" Text="Make Default" CommandName="SetDefault" runat="server" Visible="True" CommandArgument='<%#Eval("UserID") %>' CausesValidation="false"></asp:LinkButton>
<asp:Label ID="label1" Text="Yes" runat="server" Visible="False"></asp:Label>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

What I want is that when user clicks on any of the "lnk1" link button in the lsit that repeater renders,
the link should be replaced with the label "label1"..ie when the user clicks on "Make Default" link, it should be replaced with "Yes" label

Now when I click 2 link buttons, both get their label "Yes" displayed where as I want only one link button to display Yes ie the one which has been clciked and rest of the items should display "Make Default" link button only.

ie Only ONE item should be displaying "Yes" label...now how do I iterate through the repeater items to set only ONE item as default and not multiple ??

View 1 Replies

Forms Data Controls :: Way To Have More Than 1 "item Placeholder" In A Listview To Accomplish Having Multiple?

Sep 5, 2010

I need to have 3 different sections of a listview act as a repeater, but independen of each other. Each will have identical column headings, but different datasources. They will all share the same Heading, but each will have a different footer. In other words, I need to have 3 different "itemPlaceholders" in one listview.that be done.Presently, I have a panel with three listviews nested together. It works fine except that the formatting of them doesn't stay consistent.

View 2 Replies

JQuery :: How To Select Multiple Item In Drop Down And Show In A Text Box

Feb 1, 2011

how to select multiple item in drop down and show in a text box using jquery

View 2 Replies

C# - Changing The SelectedIndex Of Multiple Select Listbox To The Last Selected Item?

Jan 18, 2011

Referring to a C#, .net, System.Web.UI.WebControls.Lisbox which has a multiple select option true and needs to do a postback every time selected index changes.

Problem is, the [SelectedIndex / SelectedItem / SelectedValue] is always on the value of the 1st selected item. Clicking on the second item, third item, does not change the SelectedIndex, causing the listbox to reload and scroll to the highest selected item position.

View 5 Replies

Data Controls :: Use Multiple Eval Fields In GridView Item Template

Apr 16, 2014

Iam using the below code in ASPX for displaying images that are present inside my website project folder

<a href=""><%# Eval("Columnname","Foldername/{0}") %></a>
eg:
<%# Eval("Gallery","ImageFolder/{0}") %>
Now my question is I want to call the foldername itself from database its column name is GalleryFolder
<%#Eval("GalleryFolder")%>

How to use eval inside another eval or is there any other options??

View 1 Replies

Web Forms :: How To Filter PO Item In Invoice Entry And Avoid Duplicate Selection Of PO Item Again

Aug 22, 2010

This is the Grid am using ....

[Code]....

Every thing is working fine ....

Wat i did is in the first header of gridview dropdownlist i have binded the PO Item , so that user can select item n make invoice...

Here the problem is user will click addnewrow button to create new row second row , again user is able to select the same item what he selected in first row of gridview. here how to avoid duplication in the second row .

Say i have four PO item

Item1,Item2,Item3,item4

user may select Item1 in first row , after clicking addnewrow button user will get second row

here again user is able to select Item1 from dropdownlist ... how to avoid duplicate selection

coz the dropdownlist is binded from database using sqldatasource n filter based on user selected PO no.

Duplicate Item selection should be removed until all the four item is selected ...

View 1 Replies

Web Forms :: Redirecting A User Selected Item In A Drop Down List To Another Item?

Feb 10, 2010

I have a list with 2 sorts of items. Items that have actual values (1,2,3,4 etc) and items that are like group headings so all their values are set to 0. If someone decides to select a group heading - which has a value of 0, is it possible to redirect them to my 'Select an item' item which has a value of ""?

If worse comes to worse, I can just reconstruct the entire list, although if possible I'd like to avoid it.

View 4 Replies

Forms Data Controls :: Check If Item Exists In E.item.dataitem?

Oct 27, 2010

I use a ItemDataBound for a repeater.But i use 2 kinds of linq querys to bind it.Some of them has a MerkID, and some doesnt have this item.So its easy i need to do this:

if(e.Item.DataItem.Contains("MerkID"))

{
//Code for linq query 1

} [code]...

So of course the if selection doesnt work, but how can i do that? I already tryed this:

DataRowView drv = (DataRowView)e.Item.DataItem; if (drv.Row.Table.Columns.Contains("MerkID"))

But that doenst work because he cant convert it to a datarowview because its a linq class.So what to do? Right now i use a try and catch, but there are better solutions i guess...

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved