databind to Textbox using where clause

3 posts, 0 answers
  1. Sucheta Patil
    Sucheta Patil avatar
    52 posts
    Member since:
    Jan 2010

    Posted 19 Feb 2010 Link to this post

    Hi
    How to databind to a textbox using where clause?

    In my follwoing code,
    I want the user to enter his Surname name and using this name I want to display his picture.
    Can I use the where clause in LinqDataSource.
    Family = Request.form("txtSurname") ?

    It doesnt work in my LinqDataSource.
    Any help is appreciated.


    <div>  
    <asp:ScriptManager ID="ScriptManager1" runat="server">     </asp:ScriptManager>  
                  
    <telerik:RadPanelBar ID="RadPanelBar1" Runat="server" DataSourceID="LinqDataSource1" DataTextField="pictures" DataValueField="pictures" Width="300px">  
       <ItemTemplate>  
            <fieldset class="FramesetStyle">  
                  <asp:Label ID="lbSurname" runat ="server" Text="Family Name: " AssociatedControlID="txtSurname"> </asp:Label>       
                   <telerik:RadTextbox ID="txtSurname" runat="server"    
    Text='<%# Eval("First") %>' MaxLength="150" Width="200px">         </telerik:RadTextbox>  
                  
               <asp:Image ID="Image1" runat="server" CssClass="FramesetStyle"   
                        ImageUrl='<%# Eval("pictures") %>'   
                 AlternateText='<%# Eval("pictures""No Image Available") %>' />  
                  
                </fieldset>  
                </ItemTemplate>  
                  
            </telerik:RadPanelBar>  
            <asp:LinqDataSource ID="LinqDataSource1" runat="server"   
                ContextTypeName="ABCDataContext"   
                Select="new (Notes, email, pictures, First, Family)" TableName="tblTel">  
            </asp:LinqDataSource>  
             
  2. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 19 Feb 2010 Link to this post

    You should create a control parameter for your where clause that points to your textbox control and enable your textbox control to AutoPostback="true", to cause the picture to change.

    I hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sucheta Patil
    Sucheta Patil avatar
    52 posts
    Member since:
    Jan 2010

    Posted 19 Feb 2010 Link to this post

    
                

    hi

    <

     

    asp:LinqDataSource ID="LinqDataSource1" runat="server"

     

     

    ContextTypeName="Parabola.CWC.Forms.StaffNetDataContext"

     

     

    Select="new (Notes, email, pictures, First, Family)" TableName="tdlTeldirs"

     

     

    where="Family.ToString().Equals(@Surname)">

     

     

    <WhereParameters>

     

     

    <asp:ControlParameter Name="Surname" ControlID="txtSurname"

     

     

    Type="String" PropertyName="Text" />

     

     

    </WhereParameters>

     

     

    </asp:LinqDataSource>

     


     

    <telerik:RadTextbox ID="txtSurname" runat="server" MaxLength="150" Width="200px" AutoPostBack="True">

     

     

    </telerik:RadTextbox>

     


    I get the error:

    Could not find control 'txtSurname' in ControlParameter 'Surname'.



    Help appreciated.
Back to Top