2013-03-14 71 views
0

我使用Telerik的RadListBox控制我的web应用程序的开发,想知道怎样才能通过TextBox控件添加一行到RadListBox,下面是我的代码片段:如何在Telerik的RadListBox控件上添加和删除行?

<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"/> 

当添加按钮点击,从两个文本框获取输入并绑定到RadListBox。

对于删除,从RadListBox中选择行并单击删除按钮,从RadListBox中删除选定的行。

我的问题是如何添加和删除行?

谢谢您的高级。

回答

0

嗨,你可以创建datatable和datarows。然后将文本框值添加到dararow。那么你可以将这个数据表绑定到RadListBox。为了删除,您需要选择ListItem索引并从数据表中删除该行,然后再绑定到RadListBox。它会运行

Link for delete Row demo

与我在下面的链接后的答案还要检查。你会得到的想法有关插入行

Add rows to ListView

+0

的PL使其回答,如果这个职位帮助ü... – 2013-03-14 03:52:34