.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

Can a textbox text be used as a parameter for a where clause

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net
 

 I was wondering if there is a better way than what I am doing, if I want the text entered in the textbox to be the parameter of a where clause. I want to be able to display the records throught the gridview.

Thanks

 

 

 <<body>
    <form id="form1" runat="server">
div> 
        <br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Get_Details" />
        </div>
        <div> 
            <asp:GridView ID="GridView1" runat="server" DataSourceID="AccessDataSource2">
            </asp:GridView>
        </div>
  <asp:AccessDataSource ID="AccessDataSource2" runat="server"
     DataFile="~/App_Data/directcost.mdb" 
     SelectCommand=  "SELECT PONumber,PartNumber,QtyOrdered,Units,QtyReceived,Description,UnitCost,ExtCost,ItemNote from ASPtbPOItem where PONumber=@TextBox1.Text">
     </asp:AccessDataSource>
    </form>
</body>
</html&g


View Complete Post


More Related Resource Links

How can I use a textbox text as a parameter to a hyperlink

  

I am using a hyperlink to link to another web form page. I am not able to pass the text of textbox as a parameter.

Thanks In advance, 


Textbox text populated by Session Variable wont update into SQL with new text

  

Hi everyone, I have what I think is a weird issue. I send text from one page to another via Session Variable. When page 2 loads, the text box has the session text set, but if the user changes the text and clicks the button, the SQL database is update with the original session text. If I remove the redirect from the page 2 button_Click method, then, the page refreshes with the textbox reverting to the session text and thr SQLDataSource has the session text added to it.

Why would the button click cause the textbox refresh with the text from the pageLoad before updating the data source?

------------------------------------------------------------------------------


Partial Class _1
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Session("UpdateProd") = "Have some text here to send to a textbox on page 2"
        HttpContext.Current.Response.Redirect("2.aspx")
    End Sub
End Class
----------------------------------------------------------------------------------------------


Partial Class _2
    Inherits System.Web.UI.Page

    

Using IN clause(string parameter) in Stored Procedure

  
Hi guys. I need to use IN clause in a selection query. From all the resources that I found from google, it's all about adding a function to split a integer parameter into a list. But I got a string parameter, for example 'A1,B1,C1' I tried to use the below where single quotes in @CustCode is double up. ___________________________________ Declare @SQL VarChar(1000)   SELECT @SQL = ' SELECT [something]' SELECT @SQL = @SQL + ' FROM [Table]' SELECT @SQL = @SQL + ' WHERE CustomerCode IN ('  + @CustCode + ')'   EXECUTE (@SQL) _____________ Executing the stored procedure in MSSQL works fine, but it didn't when executing from Visual Studio 2005. Please advice.

Replace Text in textbox in word document using interop and asp.net

  
Hi all,  I'm trying to create a function to replace fields in a word document using asp.net. The fields are marked in the document using ###field### and I need to replace them with the data from the DB. The code I have works fine for the body of the word document but doesn't appear to work if the text is contained within a textbox, is there a way to correct this? Here's the code I am currently using Dim Contract as string Dim word As New Word.Application        Dim doc As Word.Document        Try            word.Documents.Open("c:\FYI.doc")            word.Visible = True             doc = word.ActiveDocument            Dim myStoryRange As Microsoft.Office.Interop.Word.Range            For Each myStoryRange In doc.StoryRanges                With myStoryRange.Find                    .Text = "###field###&quo

TextBox shows binding source text when window load, so why not with the ComboBox?

  
How can I get a ComboBox to show the binding source value when my window opens?  I have been searching all day for a solution to this, but cannot find anything.  So I have created a sample project to demonstrate my problem.  Below is a Vehicle class, very simple, two members Category and Make.  Category is an enumeration, Make is a string. namespace ComboExample { public class Vehicle { // Constants and enumerations public enum eCategory { Road, Air, Sea } // Attributes public eCategory Category { get; set; } public String Make { get; set; } // Construction public Vehicle(eCategory Category, String strMake) { this.Category = Category; this.Make = strMake; } } } Here is the C# for the MainWindow.  A new Vehicle object is created as a member.  In the constructor I set a data-provider in the XAML to this Vehicle object.  There is a button event for showing the values of the controls and objects so I can check the binding. namespace ComboExample { // Interaction logic for MainWindow.xaml public partial class MainWindow : Window { // Attributes Vehicle m_Car = new Vehicle(Vehicle.eCategory.Road, "BMW"); // Construction public MainWindow() { InitializeComponent(); // link data-p

Highlight text in a textbox

  
I have a textbox that could be 100 chars long. If I know the start & end positions of the text to highlight (via start & end position textboxes), how can I just highlight that portion of the characters in the textbox? 

Textbox in headertemplate gridview lost text in updatepanel

  
Hi everybody,I never post on this forum because since I write code in asp.net I always solve issues by finding solutions with other members who have the problem before me. But this time I don't know how to do...This is my problem : I have a gridview inside an updatepanel and i modified some headers in order to filter the collection. This worked but when my updatepanel is updating, my textbox for the filter clear the value (the text) and lost focus.Is there any solution ?This is my code : <asp:UpdatePanel ID="UpdatePanelOrders" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btFilterClear" /> </Triggers> <ContentTemplate> <asp:GridView ID="OrdersView" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True" EnablePersistedSelection="True" PagerStyle-CssClass="pager" AlternatingRowStyle-CssClass="alter_row" SelectedRowStyle-CssClass="select_row" DataKeyNames="CustId,SalesOrders,CompCode,CustPO"> <Columns>

When I click on a TextBox the text moves a little bit for Vertical Alignment

  
I have a Grid of text boxes defined in the XAML using the following code:         <Border Grid.Row="2" Grid.Column="11" Style="{StaticResource BorderStyleContent}" >             <TextBox Text="-15.11" Style="{StaticResource EditableTextBox}"/>         </Border> The styles are defined below:         <Style x:Key="BorderStyleContent" TargetType="Border">             <Setter Property="BorderBrush" Value="Black"/>             <Setter Property="BorderThickness" Value="1"/>             <Setter Property="Padding" Value="2"/>             <Setter Property="SnapsToDevicePixels" Value="True"/>         </Style>         <Style x:Key="EditableTextBox" TargetType="TextBox">         &nb

Textbox Text Property

  
I am new to VB and I have read that if I don't explicity cast variable types it will eat up performance. I have been casting certain objects, such as values from data readers, but I was wondering if the object has a property that says it is a string, like the textbox "Text" property, if I need to still cast that as a string.   Right now my code says "txtSearch.Text" but should I be using "txtSearch.Text.ToString()"?   Thanks in advance for the help!

Using multivalues parameter on sql where clause

  
Hi all, I am newbie to the report designer. I am using SQL BI Development Studio 2008 R2 to design my report. I had created the dataset to query the result I wanted to show in the report except one thing. I could not figure how to use multivalue parameter to filter the result based on the selected value the user choose. Below is the example of the query for the dataset. SELECT * FROM myTable1 WHERE myFilter IN (@myParameter) @myParameter can be any set of these: ('Value1','Value2','Value3','Value4') or ('ValueA','ValueB','ValueC') or ('ValueW','Value5','Value7') If I set the @myParameter parameter to only have a single value for each label under Available Values, the report would execute just fine. So, my question is how do go about write each label to contain a set of the values I want in the expression field. I tried to use concatenation and that didn't work. Thank you in advance. K

Unable to fetch text from a textbox with numeric up-down extender

  
I have a textbox with numeric updown extender.I want the text of the textbox.I have written code in code file is String a=txtHour.Text//  Source FIle COde<asp:TextBox ID="txtHour" runat="server" ReadOnly="True" Width="45"                     Style="text-align:center" Height="20px"></asp:TextBox>                                       <cc1:NumericUpDownExtender ID="NumericUpDownExtenderHr" runat="server"                     Enabled="True"                     Minimum="00" Maximum="23"                    TargetControlID="txtHour" Width="40">                </cc1:NumericUpDownExtender>

how to print rich textBox Formatted text

  
Hi,  I have some text in rich text box format in a table.The data is like  {\rtf1\ansi\ansicpg1252\deff0\deflang16393{\fonttbl{\f0\fnil\fcharset0 NSimSun;}{\f1\fnil\fcharset0 Microsoft Tai Le;}{\f2\fnil\fcharset0 MingLiU_HKSCS;}{\f3\fnil\fcharset0 Palace Script MT;}{\f4\fnil\fcharset0 Microsoft Sans Serif;}} {\colortbl ;\red0\green192\blue0;} \viewkind4\uc1\pard\cf1\b\f0\fs44 hello hi\par \lang1033\f1 hi i am fine\par \f2 about u?\lang16393\b0\i\f3\par \par \par \cf0\i0\f4\fs17\par }  Now,I want to print the data in corresponding format.can u please Help me.....

How to: textbox text should show only the last part of the string

  
Hi, I have a textbox that shows info. (filename) When the filename is smaller than the width of the textbox all is fine, but when the filename is longer, i would like to show the last part of the filename in stead of the first part (default). Is this possible?

Passing a Text Value as DataView Filter Parameter

  
I have a dataview to which I would like to pass a text value for use as a filter.  My text value is on the same page within a DIV tag that I have given an ID.  When I view the page in the browser the text is actually rendered in a SPAN tag, within the DIV tag.  I have tried the ID for both the DIV and SPAN tags when setting up the parameter, and have tried using both a parameter type of Control and Form, but nothing I've tried is working. Any thoughts?  Thanks, Chanda

Wish to stop user from entering text in a textbox

  
I want to stop user from entering stuff in a textbox. But if I use Readonly then for some reason I can't get the information to the database. Ant ideas? 

Report Parameter type for a list of Employees to prompt like AJAX Textbox intellisence when the user

  

Hi All,

I have around 300 employees report to run for a specific employee, I cannot have a Dropdown as it would be too long for the report user to choose from. Is it possible in SSRS 2008 to have a text box that would provide intellisence like AJAX textbox and provides user with Employee name to choose from database or is there any other better way to select the right mployee name to run this kind of report. being a newbie to SSRS I am unable to go furthur on this. All help is great help. Thanks in advance for responding.


Text selection in textbox on mouse over

  
Hi,

I am having a Textbox and want to selcted text with perticular format on mouse over.

So if my text in textbox is "This person <<PersonName>> has a good experience of <<Year>> in <<Technology>>". Now if I put my mouse over <<PersonName>> or <<Year>> or <<Technology>>, only this text (<<PersonName>>, etc) should be highlighted. 



How can I start implementing this as I know Textbox in WPF/Silverlight doesn't provide this behavior.

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend