views:

64

answers:

1

I have a simple test.aspx page with one Button control with ID="btnSearch" and TextBox control with ID = "txtSearchbyName". The functionality is to get all values from SQL server table called as "TestTable" based on text in TextBox like "select * from testtable where firstName = txtSearchbyName.text"

I have a simple grid with SQLDatasource created with the GUI interface and have a select query with where clause added through GUI in SQLDataSource similar as above query.

When I hit F5 and enter a text in TextBox like "testing" and hit enter, I get the grid filled with all matching firstName populated in the grid.

I have couple of queries now.

  1. Without using codebehind file (test.aspx.cs file) or no C# code or javascript, How to populates GridView only using SQLDataSource GUI or HTML tag in aspx.file, when I specify text in TextBox and hit\click the button control in current test.aspx page. Again I reiterate, I don't want to use codebehind and javascript.

  2. How to disable the functionality when I hit enter within the TextBox after entering text so that the GridView is not populating the grid at all.

Basically I want the search to be enabled using button only and without any coding but I am allowed to make changes in html.

Also, please make sure any other control on the form should not populate the gridView at all.

Thanks in Adavance.

Manu

A: 

You can use a SQLDataSource like this one

<asp:sqldatasource
    id="SqlDataSource1"
    runat="server"
    connectionstring="<%$ ConnectionStrings:YOURCONNSTRING%>"
    selectcommand="select * from testtable where firstName = @firstName ">
    <selectparameters>
        <asp:controlparameter name="firstName" controlid="txtSearchbyName" propertyname="Text"/>
    </selectparameters>
</asp:sqldatasource>

When you click the button the Page will postback and then load the data. But keep in mind that any postback, not only the button will cause the data to load.

Carlos Muñoz
I want to do load the data on only button click not on any other Postback and that's what my original question was.
Manju
@Manju - you cannot do this without logic in the codebehind.
Josh
Can anyone tell me more on this..I need urgent help...need solution for the original question..dont want to use anyscripting or code behind or Microsoft have this bug?????
Manju