Bind ListView

2 posts, 0 answers
  1. MKM
    MKM avatar
    2 posts
    Member since:
    Aug 2012

    Posted 14 Aug 2012 Link to this post

    Hi all,

    My web page has got a asp:TextBox and a listview, initially the listview is not visisble.When user type a text inside the TextBox I want a listview bound with the database. Exactly my requirment is to bind list view depanding upon the value typed in the textbox.
    My sqlquery to extarct the value fron the db is."SELECT patientOrg, surgeryDate FROM DetailsChart WHERE patientName ="text from textbox"

    Reply as soon as possible.

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Aug 2012 Link to this post

    Hi MKM,

    Try the following code snippet to achieve your scenario.

    <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" AutoPostBack="true"></asp:TextBox>
    <telerik:RadListView ID="RadListView1" runat="server" ItemPlaceholderID="itemPlaceholder" Visible="false">
         <tr align="left">
            <td align="center">
               <asp:Label ID="Label1" Text='<%# Bind("patientOrg") %>' runat="server" />
            <td align="left">
               <asp:Label ID="Label2" Text='<%# Bind("surgeryDate") %>' runat="server" />
            <table cellpadding="10" cellspacing="0" class="stripe" width="100%" id="tblResults">
                 <td width="50" align="center">
                 <td width="100" align="left">
               <asp:PlaceHolder ID="itemPlaceholder" runat="server" />

    protected void TextBox1_TextChanged(object sender, EventArgs e)
       TextBox txt = (TextBox)sender;
       string t = txt.Text;
       String s = "SELECT patientOrg,surgeryDate FROM DetailsChart WHERE patientName='" + t + "'";
       SqlDataAdapter dr = new SqlDataAdapter(s, con);
       DataTable dt = new DataTable();
       RadListView1.Visible = true;
       RadListView1.DataSource = dt;

    Hope this helps.

Back to Top