This is a migrated thread and some comments may be shown as answers.

Listbox inside grid

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
maha
Top achievements
Rank 1
maha asked on 25 Jul 2008, 09:30 PM
I have 2 listbox inside the grid as shown below

<

td width="90%">

<table width="95%" border="1">

<tr>

<td>

<span style="font-weight: bold; font-size: 10pt"></span>

<%

--<asp:Label ID="lblAccountNumber" runat="server" Text='<%# Bind("AccountNumber") %>'

Font-Bold="true" Font-Size="10"></asp:Label>--

%>

<br />

<asp:ListBox ID="lbAllAccountNumbers" runat="server" Width="300" Height="200" SelectionMode="Multiple">

</asp:ListBox>&nbsp;&nbsp;&nbsp;

<ajaxToolkit:ListSearchExtender ID="SearchAllAccount" TargetControlID="lbAllAccountNumbers"

runat="server">

</ajaxToolkit:ListSearchExtender>

<asp:ImageButton ID="btnSelect" ImageUrl="~/images/right.jpg" ImageAlign="Middle" runat="server" OnClick="btnSelect_Click" />

<asp:ImageButton ID="btnUnselect" ImageUrl="~/images/left.jpg" ImageAlign="Middle" runat="server" OnClick="btnUnselect_Click" />

<ajaxToolkit:ListSearchExtender ID="SearchAvailableAccounts" TargetControlID="lbAvailableAccountNumbers"

runat="server">

</ajaxToolkit:ListSearchExtender>

<asp:ListBox ID="lbAvailableAccountNumbers" runat="server" Width="300" Height="200"

SelectionMode="Multiple"></asp:ListBox>

</td>

</tr>

</table>

</td>
The above code is in EditFormSettings tab.
When edit button is clicked iam loading two listboxes with some data.
In between those two listboxes , i have two buttons which will select or unselect from the above list boxes. When an item or items is selected in the listbox and clicked on Button, i have to move those items selected in the listbox to the other listbox.

I am writing this code in the button click event.

But in the button click , iam not able to gt the listbox.
Is there a way to get a reference to the listbox in the grid when the grid is in edit mode.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 28 Jul 2008, 05:13 AM
Hi maha,

You can get controls in grid EditForm easily from button click if you cast the sender argument to Control, get the control NamingContainer (which is GridItem)  and  use FindControl() method:

ListBox MyListBox = (ListBox)((Control)sender).NamingContainer.FindControl("MyListBox");

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
maha
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or