Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 5th, 2007, 08:08 AM
Registered User
Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagridview

  i am new dot net .
     i have one listbox and datagridview.
     when i select or click the listbox item it will come to datagrid view.i will click the list box more number of times .all the time values should add the data grid view.

help me..

Old April 7th, 2007, 03:35 AM
Friend of Wrox
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post

ok, I'll try to explain a simple logic here, which you can implement. First off, you can create a datagrid and bind a column within it, say with the name "ItemName", e.g.

<asp:BoundColumn DataField="ItemName" HeaderText="Item"></asp:BoundColumn>

Now, within the server side code, you can create a datatable, create a column with the name "ItemName", now simply check for the no of items selected in the listbox, & according to that, follow the steps below:

1. Create new rows in the datatable.
2. Assign the selected value of listbox in the datarow.
3. Bind the datagrid with the datatable.
4. Update a viewstate with this datatable.

(Let me explain the purpose of viewstate. Each time a new item is selected from the listbox, we will first check if viewstate exists, if not create a new datatable, else append the datatable with the existing viewstate.)

5. Finally remove the selected items from listbox.

Any issues, let me know.


Fortune favours the brave, so don't regret on missed oppurtunities.

Similar Threads
Thread Thread Starter Forum Replies Last Post
datagridview help manius VB Databases Basics 1 January 27th, 2008 02:44 AM
DatagridView in C# velan C# 2005 0 June 8th, 2007 09:25 PM
DataGridView Sakkaw C# 2005 1 January 9th, 2007 12:06 PM
DataGridView akumarp2p C# 2005 1 December 30th, 2006 12:40 PM
datagridview ScottSheck Visual Basic 2005 Basics 0 June 14th, 2006 11:07 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.