ASP.NET - how to add the items in the textbox on clicking in the listbox

Asked By pradnya
31-Jul-10 01:06 AM


I have one listbox in that all the table fields are displayed when i click on any field it should display with the query such as select studentID from student table  and the query should be with proper constraints and it should contain all the relations if that table exists(such as inner join,groupby etc).
  kiruba .e replied to pradnya
31-Jul-10 01:24 AM
hi, just try this..



protected void Button1_Click(object sender, EventArgs e)

{

for (int i = 0; i <= ListBox1.Items.Count - 1; i++)

{

if (ListBox1.Items[i].Selected)

TextBox1.Text = TextBox1.Text + ListBox1.SelectedItem.Text;

}

}

  Goniey N replied to pradnya
03-Aug-10 12:07 AM
On The Listbox SelectedItem Event, Write Below One Line Code :

txtName.Text = LstBoxName.SelectedItem.Text;


//It Will Store Selected Item From Listbox Into Your Textbox.


//I Think This One Is Simple Code For You....
Create New Account
help
photo albam how to create photo albam using asp.net Have a look at the following sample projects: • This article explains an ASP.NET application to view and share photos online. http: / / www.codeproject.com / KB / applications / NetPix.aspx • Shows how to store images in SQL Database Image Storage & create Thumnails easiliy from http: / / www.codeproject.com / KB web-image / EasyThumbs.aspx • How to upload files to Web pages in ASP.NET? How to read an image from a database using ADO.NET and display it in of all of that few best one are these, just help your self http: / / weblogs.asp.net / bleroy / archive / 2005 / 09 / 08 / a-simple-asp-net-photo-album.aspx http: / / www
1: Creating the Batch Deleting Interface Step 2: Deleting the Checked Products Using Transactions The Selected Products Will Be Deleted Figure : The Selected Products Will Be Deleted &nbsp; The Deleted Products ProductID Values are Listed Beneath the GridView Beneath the GridView Please refer the follow the website for code, procedure & image http: / / www.asp.net / data-access / tutorials / batch-deleting-cs For that you have to handle RowDeleting event of Just go thr this code which will explain the same; protected void Page_Load(object sender, EventArgs e) { / / public event GridViewDeleteEventHandler RowDeleting(gv1, e); if (!Page.IsPostBack) { gv.DataSource = createDataSet(); gv.DataBind must keep at least one record."); } else { if (gv1.SelectedIndex > = 0) { / / dt1.Rows.IndexOf(gv1.Selected); dt1.Rows.RemoveAt(gv1.SelectedIndex); e.Cancel = false; gv1.DataSource = createDataSet(dt1); gv1.DataBind(); gv1.Visible = true; } } } protected void gv1_SelectedIndexChanged(object sender, EventArgs e) { } } Cheers For Your task, you vahe to use GridView1_RowDeleting Event of GridView Control(). I the GridView. If a row is checked, the code retrieves the EmployeeID and passes the selected value to the Delete Command. C# protected void btnMultipleRowDelete_Click( object sender, EventArgs e) { / / Looping through
class _Default : System.Web.UI.Page { System.Text.StringBuilder SelectedCountriesId = new System.Text.StringBuilder(); / / Will store the all the IDs protected void Page_Load( object sender, EventArgs e) { lstCountry.SelectionMode = ListSelectionMode.Multiple; } protected void lstCountry_SelectedIndexChanged( object sender, EventArgs e) { foreach (ListItem country in lstCountry.Items) { if (country Selected) SelectedCountriesId.AppendFormat( "{0}, " , country.Value ); / / Build Comma-separated values } SelectedCountriesId.Remove( SelectedCountriesId.Length-1, 1 i have worked on one listbox and the result should be displayed in gridview my asp.net code <form id = "form1" runat = "server"> <div> < / div> <asp:ListBox ID = "ListBox1" runat = "server" AutoPostBack Degree, a.YearsExp, a.Speciality, a.EmpID, a.StartDate, a.EndDate FROM WL_employeedetails AS a INNER JOIN WL_coredetails AS b ON a.CoreID = b.CoreID INNER JOIN WL_roledetails AS c ON a.RoleID = c.RoleID WHERE (a.CoreID = @coreID) AND (c