Working on Datagrid with Listboxes !!

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2005
Posts: 19
Reputation: cumadhu is an unknown quantity at this point 
Solved Threads: 0
cumadhu cumadhu is offline Offline
Newbie Poster

Working on Datagrid with Listboxes !!

 
0
  #1
Oct 3rd, 2005
Hi All,
I have specific requirement in asp.net project.
I have datagrid, in that in have one dotnet list control which stores the items.And it is multiselect. Onclicking >> button i want to move selected items from dotnetListControl to HTML Select(listbox) control.
In DataGrid:
DotnetListBOX Control(i multiselect few items then)---> >>(Click on the button) ----> add to new listbox(Html Select)

I tried with ItemDataBound but still i could not able to get it.
(Problem: When Datagrid is rendered, i am not able to get unique id for HTML select control).

Kindly let me know if any other good idea ...

Thanks and with regards,

Madhusudhan
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 8
Reputation: akadez is an unknown quantity at this point 
Solved Threads: 0
akadez akadez is offline Offline
Newbie Poster

Re: Working on Datagrid with Listboxes !!

 
0
  #2
Oct 3rd, 2005
Not sure if this is what you are attempting to do.

Scenerio

Datagrid has a 2 listbox controls. When clicking >> button, click event should move selected items from listbox1 to listbox2

Solution

  1. 'Code within >> button click event
  2. For Each gridItem As DataGridItem In DataGrid1.Items
  3. Dim list1 As ListBox = CType(gridItem.FindControl("List1"), ListBox)
  4. Dim list2 As ListBox = CType(gridItem.FindControl("List2"), ListBox)
  5.  
  6. For Each item As ListItem In list1.Items
  7. If item.Selected Then
  8. list2.Items.Add(item)
  9. End If
  10. Next
  11. Next
  12.  
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 19
Reputation: cumadhu is an unknown quantity at this point 
Solved Threads: 0
cumadhu cumadhu is offline Offline
Newbie Poster

Re: Working on Datagrid with Listboxes !!

 
0
  #3
Oct 4th, 2005
Even >> button is in the same grid.
If there are 5 rows in a grid, then
listbox1 >> buttons Listbox2
listbox1 >> buttons Listbox2
listbox1 >> buttons Listbox2
listbox1 >> buttons Listbox2
listbox1 >> buttons Listbox2
will appear.The IDs for all these control after rendering is different like dgGrid_ctl2:listbox1
dgGrid_ctl3:listbox1 etc ...
Similarly for >> button and listbox 2.

Still i could not able to fix this error.
Kindly provide some more details.

Thanks and with regards,
Madhusudhan
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 19
Reputation: cumadhu is an unknown quantity at this point 
Solved Threads: 0
cumadhu cumadhu is offline Offline
Newbie Poster

Re: Working on Datagrid with Listboxes !!

 
0
  #4
Oct 4th, 2005
I mean to say:
I dont want to refresh page everytime i click the image button.
I need to add this from server.
Like writeing javascript in class file.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 8
Reputation: akadez is an unknown quantity at this point 
Solved Threads: 0
akadez akadez is offline Offline
Newbie Poster

Re: Working on Datagrid with Listboxes !!

 
0
  #5
Oct 4th, 2005
[HTML]<!-- Code in ASPX DataGrid -->
<ItemTemplate>
<input type="button" value="Move" onclick="javascriptwapList('<%# (Container.ItemIndex + 1) %>');">
</ItemTemplate>[/HTML]

  1. //Javascript Code:
  2. //function should take an input of the current index
  3. function SwapLists(idx) {
  4.  
  5. var inpt = document.frmProdDetail.getElementsByTagName("input");
  6. var list1, list2;
  7.  
  8. for (var i = 0; i < inpt.length; i++)
  9. {
  10.  
  11. if (inpt[i].id.match('ctl' + idx + '_MyAspxListBox1') != null) {
  12. list1 = inpt[i];
  13. } else if (inpt[i].id.match('ctl' + idx + '_MyAspxListBox2') != null) {
  14. list2 = inpt[i];
  15. }
  16. }
  17.  
  18. //Write your javascript to transfer selected items from list1 to list2
  19. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC