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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Filtering with gridview + (search function)

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
      have a gridview and  6 dropdownlists which I want to use to filter data in gridview I am using this code below Try            strSql = "Select * from aspnet_Users where UserName = " & Me.DropDownList1.SelectedItem.Text            Call OpenConnection()            Call GiveCommand(strSql)            sqlMyCmd.ExecuteNonQuery()            Me.GridView1.DataSource = sqlMyCmd.ExecuteReader            Me.GridView1.DataBind()            Call EndConnect()        Catch ex As InvalidOperationException        Catch ex2 As SqlException        Catch ex As NullReferenceException        End Try what im trying to acheive on the page is to allow user to pick a value from any1 of the 6 dropdownlist (representing  6 fields) and when btnSearch is clicked Gridview displays the data the code I have above allows me to do this with one dropdown

View Complete Post

More Related Resource Links

gridview filtering using a codebehind (textbox + search button)

i am trying to replicate the following sequence: input text into text box > press search button > search a database using LIKE operator > display using a gridview or listview. this sequence is fairly easy to do using the drag and drop then sqldatasource options, but i am trying to do the same result using a codebehind.  here is my code:   ____________________________________________________________________________________________________________ SqlConnection myConn; myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\projectDB.mdf; Integrated Security=True;User Instance=True"); myConn.Open(); string strSQL; strSQL = "SELECT * FROM Message";       //strSQL = "SELECT * FROM Message WHERE Message LIKE '" + txtSearch.Text + "'"; SqlDataAdapter da = new SqlDataAdapter(strSQL, myConn); DataSet ds = new DataSet(); da.Fill(ds, "Message"); GridView1.DataSource = ds; GridView1.DataBind(); myConn.Close(); _____________________________________________________________________________________________________________  now, if I use this code inside a page_load event, it does work. if I put it inside a button_click event i get nothing. i am mystified by this.. any help? why can't i use a button to display my gridview1 when i'm using a code behind.  

Gridview + Search Function


Does anyone know where i can find good toturials where you can make a search function and show the results in a gridview?

Tutorials are welkom.


GridView Filtering In ASP.NET

In this tutorial you will learn how to add a filter to a Grid View Control, To modify the query with a parameterized filter, the WHERE Clause, Parameter properties, Parameter Value Editor and To test filtering.

search multiple words into textbox and populate all records in gridview related those keywords


I have a textbox and a gridview which is bound to a table

what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;

1. Book

2. Red

I have set up the sql data source and everything and my like operator is this...

LIKE '%' + @record + '%'

how can I solve this problem?

How to create a "search function" to find files and folders using C++ windows forms?

As mentioned above, how can I make a windows forms application that searches for files and folders specified by the user and display results in a ListBox? Thanks in advance another question: How can I make a textbox transparent? I would be really grateful if anybody told me what books are good to learn windows forms using C++? thanks again

Filtering GridView?

I have a web page with a GridView control populated from a database.  I want to have a form that users can use to filter the results presented in the GridView.  For example, it might have fields for last name, first name, department, wages, date of hire, etc. that the user can fill out to filter the results.  Is there an elegant way of doing this?  The only thing that comes to mind is to test the value of each field and then have a database query string for every outcome.  For example, if the user only inputs a last name, the query might be SELECT * FROM EMPLOYEE ... WHERE LastName = @LastName.  If they input both last name and department, the query would be SELECT * FROM EMPLOYEE ... WHERE LastName = @LastName AND Department = @Department.  This seems like it would get unwieldy very quickly.  Any suggestions on a better method? 

centralized search function in Sharepoint 2010?

Dear Folks , 1.How to use Centralized Search function in Sharepoint 2010 2.Search indexing 3.Control over what content to be available in search 4. how to display the  top searches in sharepoint 2010? please find and give me some valuable comments thank you Regards  

Search for Gridview on Eventhandler

Hello, I was woundering if there is a way to seach for a gridview on event handler.? I have three gridviews in which i can insert from and on my insertbutton codebehind, I want to check the gridview i am using so i could get the datakeynames for insert into the database. Does anyone have ideas. Thaks  

How can i pass function as parameter to show in gridview

Hello, I have one common Data Access function which returns output as dataset which is as below   Public Shared Function ExecuteDataSet(ByVal sql As String, ByVal type As CommandType, ByVal ParamArray parameters As SqlParameter()) As DataSetDim RetVal As Object = Nothing   Try Cmd = Cmd.Connection = OpenConnection() Cmd.CommandType = type Cmd.CommandText = sql Cmd.Parameters.AddRange(parameters) Sda = Ds = Sda.Fill(Ds)       New SqlCommand()New SqlDataAdapter(Cmd)New DataSetCatch ex As ExceptionThrow New Exception(ex.Message.ToString())Finally CloseConnection() Sda.Dispose() End Try   Return Ds End Function   this function normally i use to get data from database and returns to dataset   now,I want to created one more function which output type is gridview and its parameter is  dataset which i got output in previous funtion   i want like this public funtion BindDatatoGridView(ExecuteDataSet("SELECT...",commandType.text,Parameter....)) as GridView End Function   how can i solve this, please help me out

search option in gridview

I am creating small application.  I want to keep textbox and gridview. If i type any alphabets in text box like customers name  if i type a it should display customers name with starting a in gridview. plz help methanq.

SharePoint Farm Backup Error in Search instance function

I'm working with MS Project Server 2007 with SharePoint WSS. When doing a full farm backup in SharePoint Central Admin > Operations > Backup and Restore > Perform a Backup, I encountered 2 errors in "SharePoint Windows Services Search, Search instance". 1) Error: Object a8b2cbfe-ef8b-45ce-92a0-c5675f534ec0 failed in event OnBackup. For more information, see the error log located in the backup directory.  InvalidOperationException: System.NullReferenceException: Object reference not set to an instance of an object.    at Microsoft.SharePoint.Search.Administration.SPSearchBackupRestoreTimerJob.Execute(Guid targetInstanceId)   2) Error: Object a8b2cbfe-ef8b-45ce-92a0-c5675f534ec0 failed in event OnBackupComplete. For more information, see the error log located in the backup directory.  Object a8b2cbfe-ef8b-45ce-92a0-c5675f534ec0 failed in event OnBackup. For more information, see the error log located in the backup directory.  InvalidOperationException: System.NullReferenceException: Object reference not set to an instance of an object.    at Microsoft.SharePoint.Search.Administration.SPSearchBackupRestoreTimerJob.Execute(Guid targetInstanceId)  InvalidOperationException: System.NullReferenceException: Object reference not set to an instance of an object.    at Microsoft.SharePoint.Search.Administ

pass number of rows of Gridview to a javascript function

using vb.net/asp.net 2005.I need to pass the number of rows of the Gridview to a javascript function does anyone know how to do this?  thanks

how to move to particular pageindex in gridview when i search

 Hi, I have one textbox one button and one gridview on my webform, when Page loads all records are displayed on gridview, which works perfectly fine, Now,I search particular records by entering id in textbox, which finds particular records and found row's background becomes red.which works perfectly fine too, my gridview's pagesize is 15 which means it display 15 records per page,   Now,Problem is when i enter ID textbox to search record,but searched record is on another page,so,I want that When i click button to search, the page must be displayed where searched record exist. It displays first page even after search, How can i move to that page where record exist.   what i have to code in click event Regards,ASIF

Sharepoint foundation search function

On my homepage, after giving a search command in the general search box, the page says there is no indexing function applyed. I have looked through the site settings and central administration but cant find anything related. Take note this is on sharepoint foundation, not sure if that makes a difference or not. Thanks

how to use Trim Function in gridview

<asp:TemplateField HeaderText="status" SortExpression="status"> <ItemTemplate>  <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("status") %>'></asp:TextBox> <asp:RadioButtonList ID="rbgpstatus" runat="server" SelectedValue='<%# Bind("status") %>'> <asp:ListItem Value="S">Scheduled</asp:ListItem> <asp:ListItem Value="Approved">Approved</asp:ListItem> <asp:ListItem Value="R">Rejected</asp:ListItem> </asp:RadioButtonList> </ItemTemplate> </asp:TemplateField>   my radio buttonlist always comes up eith error that 'rbgpstatus' has a SelectedValue which is invalid because it does not exist in the list of items....so i winder the bind property of status got some extraspace in left and right side...i want to use trim before bind("status")..how to use that   

Using search with stored procedure and redisplaying in one gridview

I am using two SQL Data Adapters to initially populate a gridview and then repopulate from search results.  The Search SQL Data Source uses a stored procedure to retrieve the results but I cannot get the updated gridview to display. Here is my aspx code:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>All Reqeusts Data View and Editing Page</title> </head> <body> <form id="form1" runat="server"> <div> </div> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:SqlDataSource ID="AllRequestsSearchSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:artworkrequestsConnectionString %>" SelectCommand="artworksearch" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="BeginDat

I want to filter the gridview on textchange in search textbox....


hi friends...
i want to filter the gridview on textchange in search textbox....
if i press "a" the gridview should filled up with record starting with "a". i have some code

SqlDataSource1.SelectCommand = "select * from DeptMaster where DeptName like '" + TextBox1.Text + "%'";
        SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.Text;
        GridView1.DataSource = SqlDataSource1;

its working while leaving the textbox but i want this code should execute on keypress event....

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