Update DataSource

2 posts, 0 answers
  1. Deivison Julio
    Deivison Julio avatar
    3 posts
    Member since:
    Feb 2012

    Posted 17 Apr 2012 Link to this post

    How do I update a datasource for a listbox via code by clicking on a button? Something like ListBox.DataSource.Update (), Listbox.ResetBind (), do not know ... 
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Apr 2012 Link to this post

    Hi Deivison Julio,

    You can use DataBind method while binding at Runtime as follows.

    <telerik:RadListBox ID="RadListBox1" runat="server">
    <asp:Button ID="Button1"  runat="server" onclick="Button1_Click" />
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"  SelectCommand="SELECT EmployeeID FROM [Employees]" ConnectionString= "<%$ ConnectionStrings:NorthwindConnectionString %>">

    protected void Button1_Click(object sender, EventArgs e)
           RadListBox1.DataSourceID = "SqlDataSource1";
           RadListBox1.DataTextField = "EmployeeID";
           RadListBox1.DataValueField = "EmployeeID";

    For more information please take a look into this.

Back to Top