javascript search functionality

Posted by Kranthi under ASP.NET on 11/11/2010 | Points: 10 | Views : 1205 | Status : [Member] | Replies : 4
i have 7 textboxes one search button and one gridview...user enter input in anyone textbox for search the datas.....and the result should be displayed in gridview. using javascript .How to do this.please any one send me the answer

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None"
Width="933px" onrowdatabound="GridView1_RowDataBound"

>
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:HyperLinkField DataTextField="FirstName" HeaderText="FirstName"
NavigateUrl="~/SaveContacts.aspx" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="Address1" HeaderText="Address1"
SortExpression="Address1" />
<asp:BoundField DataField="Address2" HeaderText="Address2"
SortExpression="Address2" />
<asp:BoundField DataField="State" HeaderText="State"
SortExpression="State" />
<asp:BoundField DataField="City" HeaderText="City"
SortExpression="City" />
<asp:BoundField DataField="Phone" HeaderText="Phone"
SortExpression="Phone" />
<asp:BoundField DataField="Mobile" HeaderText="Mobile"
SortExpression="Mobile" />
<asp:BoundField DataField="ZIP" HeaderText="ZIP"
SortExpression="ZIP" />
<asp:BoundField DataField="EmailID" HeaderText="EmailID"
SortExpression="EmailID" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</p>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:contactsConnectionString4 %>"

SelectCommand="SELECT FirstName,LastName,Address1,Address2,State, City, Phone, Mobile, ZIP, EmailID FROM addcontacts where (FirstName LIKE '%' + @FirstName + '%') AND (LastName LIKE '%' + @LastName + '%') AND (Address1 LIKE '%' + @Address1 + '%') AND (State LIKE '%' + @State + '%') AND (City LIKE '%' + @City + '%') AND (ZIP LIKE '%' + @Zip + '%') AND (EmailID LIKE '%' + @EmailID + '%')""
FilterExpression ="FirstName='{0}'">
<FilterParameters >
<asp:QueryStringParameter Name ="FirstName" QueryStringField ="FirstName" />
<asp:Parameter Name ="LastName" Direction ="Output" DefaultValue ="0" />
<asp:Parameter Name ="Address1" Direction ="Output" DefaultValue ="0"/>
</FilterParameters>

</asp:SqlDataSource>




Responses

Posted by: Madhuk on: 11/11/2010 [Member] Starter | Points: 25

Up
0
Down
Confirm whether your textboxs and button are inside the GridView or out of it.

Kranthi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 11/11/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Good Day Kranthi

when you say


using javascript .How to do this.please any one send me the answer


What do you mean, what is the source of data you want to search ?

Thank you for posting at Dotnetfunda
[Administrator]

Kranthi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kranthi on: 11/11/2010 [Member] Starter | Points: 25

Up
0
Down
my textboxes are out side the gridview only....


Kranthi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhuk on: 11/12/2010 [Member] Starter | Points: 25

Up
0
Down
So you dont have any problem with javascript validation with code I answered in your previous question.

In your button click event bind the gridview.
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="GetElemets()

" onclick="Button1_Click" />
protected void Button1_Click(object sender, EventArgs e)
{
BindGridView();
}


You are having problem with your query What do i suggest is open your sql query analyzer and check the sql query for some values and use the same to bind the GridView.

Kranthi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response