简体   繁体   中英

How can I add and delete row on Telerik's RadListBox Control?

I'm using Telerik's RadListBox control for my web application development, wondering how can I add row into RadListBox via TextBox control, below is my code fragment:

<telerik:RadListBox ID="rlbControl" runat="server" SelectionMode="Multiple"> 
   <ItemTemplate> 
      <table>
       <tr>
           <td>
               <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' ></asp:Label>
           </td>
           <td style="width:20px"></td>
           <td >
               <asp:Label ID="lblAge" runat="server" Text='<%# Eval("Age") %>' ></asp:Label> 
           </td>
       </tr>
     </table>
   </ItemTemplate> 
</telerik:RadListBox> 

Name : <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
Age : <asp:TextBox ID="txtAge" runat="server" ></asp:TextBox>

<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click"  />
<asp:Button ID="btnDel" runat="server" Text="Delete" OnClick="btnDel_Click"/>

When Add button click, get input from two TextBox and bind into RadListBox.

For deleting, select row from RadListBox and click on Delete button, remove the selected row from the RadListBox.

My question is how can I add and delete rows?

Thank you in advanced.

Hi you can create datatable and datarows. then add the textbox values to dararow. then u can bind this datatable to the RadListBox. For deleting, u need to pick the ListItem index and delete the row from the datatable and again bind to the RadListBox. It will work..

Link for delete Row demo

Also check with my answer in the below link post. you will get idea about insert row

Add rows to ListView

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM