This is a migrated thread and some comments may be shown as answers.

databind to Textbox using where clause

2 Answers 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sucheta Patil
Top achievements
Rank 1
Sucheta Patil asked on 19 Feb 2010, 01:05 PM
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 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 19 Feb 2010, 02:16 PM
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.
0
Sucheta Patil
Top achievements
Rank 1
answered on 19 Feb 2010, 02:32 PM

            

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.
Tags
General Discussions
Asked by
Sucheta Patil
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Sucheta Patil
Top achievements
Rank 1
Share this question
or