943,539 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 4948
  • ASP.NET RSS
Oct 3rd, 2005
0

Working on Datagrid with Listboxes !!

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cumadhu is offline Offline
19 posts
since Sep 2005
Oct 3rd, 2005
0

Re: Working on Datagrid with Listboxes !!

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

ASP.NET Syntax (Toggle Plain Text)
  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.  
Reputation Points: 10
Solved Threads: 0
Newbie Poster
akadez is offline Offline
8 posts
since Sep 2005
Oct 4th, 2005
0

Re: Working on Datagrid with Listboxes !!

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cumadhu is offline Offline
19 posts
since Sep 2005
Oct 4th, 2005
0

Re: Working on Datagrid with Listboxes !!

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
cumadhu is offline Offline
19 posts
since Sep 2005
Oct 4th, 2005
0

Re: Working on Datagrid with Listboxes !!

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

ASP.NET Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
akadez is offline Offline
8 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Final Year Project (HELP!!)
Next Thread in ASP.NET Forum Timeline: about CDONTS





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC