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

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

how to move to particular pageindex in gridview when i search

Posted By:      Posted Date: September 11, 2010    Points: 0   Category :ASP.Net
 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

View Complete Post

More Related Resource Links

GridView: Move Over DataGrid, There's a New Grid in Town!


When incorporating the ASP.NET DataGrid control into your Web apps, common operations such as paging, sorting, editing, and deleting data require more effort than you might like to expend. But all that is about to change. The GridView control--the successor to the DataGrid-- extends the DataGrid's functionality it in a number of ways. First, it fully supports data source components and can automatically handle data operations, such as paging, sorting, and editing, as long as its bound data source object supports these capabilities. In addition, the GridView control offers some functional improvements over the DataGrid. Here DataGrid expert Dino Esposito introduces the GridView and explains all its long-awaited features.

Dino Esposito

MSDN Magazine August 2004

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?

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.  

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  

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.

Move Sharepoint Search Administration Component

I am failing to transfer the Sharepoint Search Administration component from one Application Server to another. Using the -Force parameter generates the same result. The $admin and $searchInstance are valid objects. Seems a bit chicken and egg. I am trying to move the web service and the complaint is that the web service is not on the server! PS C:\Users\sp2010setup> $admin | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance $searchInstance Set-SPEnterpriseSearchAdministrationComponent : SharePoint Server Search Admin Web Service is not started on server FOOBARSAS2. Please start it and try ag ain. At line:1 char:55 + $admin | Set-SPEnterpriseSearchAdministrationComponent <<<<  -SearchServiceIn stance $searchInstance     + CategoryInfo          : InvalidData: (Microsoft.Offic...rationComponent:    SetSearchAdministrationComponent) [Set-SPEnterpris...rationComponent], Inv   alidOperationException     + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.SetSearchA    dministrationComponent

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

Filtering with gridview + (search function)

      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

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....

MOSS 2010: how to move the "Search this site..." box to above the Nav Bar instead of on it

Am a novice, but can get around Sharepoint Designer. In MOSS 2010, how do I move the "Search this site..." box to above the Nav Bar instead of on it?

Extend the OOB Search Box to move to SearchResults.aspx page


Is there any chance to redirect the OOB search box web part to redirect to SearchResults.aspx page if a custom scope is chosen?

My requirement is to implement, Search for "All Sites", People, Current Site, Network Share, Custom Search which uses a web service. The requirement is to have all the above scopes in the dropdown menu. We are able to have all scopes instead of Custom search which need to be redirected to a page in the dropdown. Is it possible to have an entry in the dropdown to redirect to a search page? Can we use the export of OOB Search box to add an entry in scope dropdown?

Kindly help.

How do I set the PageIndex property of a GridView?


In my web-based project, I pass an ID field as a parameter in my URL and go through each row in my gridview to find the correct row that matches the ID parameter. I am in the DataBound evet of my GridView

REM if ID parameter was given in URL
If Not Request.QueryString("ID") Is Nothing AndAlso _
IsNumeric(Request.QueryString("ID")) Then

Dim bItemNotFound As Boolean = True

REM i is the Page index counter
Dim i As Integer = -1

REM j is the row counter for each page
Dim j As Integer = -1

Dim selected_index As Integer = -1

For i = 0 To GridView1.PageCount - 1

REM This line gives an error
GridView1.PageIndex = i

For j = 0 To GridView1.DataKeys.Count - 1
If Request.QueryString("ID") = GridView1.DataKeys(j).Value Then
bItemNotFound = False
selected_index = j
Exit For
End If

If bItemNotFound = False Then
Exit For
End If

If bItemNotFound = False Then
GridView1.SelectedIndex = selected_index
GridView1.PageIndex = 0
GridView1.SelectedIndex = -1
End If
End If

Why can I no

Using search engine with GridView


Hi guys,

I'm binding database with GridView by SQLDataSource. Now if I want to search based on one of the database column (for e.g. search by date), how can I do it? 

Search an in a GridView



I would like to add a trigger to the UpdatePanel, the control is an ImageButton in a gridView like this:

                                <asp:TemplateField HeaderText="" ShowHeader="False">
                                    <%--<HeaderStyle Wrap="False" Width="25px" />--%>
                                    <ItemStyle HorizontalAlign="Left" Wrap="False" Width="25px" />
                                        <asp:ImageButton ID="imgDetalle" runat="server" CausesValidation="false" CommandName="VerDocumento"
                                            ImageUrl="~/imagesExterna/icoDetalle.gif" CommandArgument='<%# Eval("NOMBRE_DOCUMENTO") %>'
                                            ToolTip="Ver Documento" />
                                    <ItemStyle HorizontalAlign="center" Wrap="False" />

How can I add in codeBehind the trigger?? my code is this but

Search GridView and update the row that was found


 I have a gridview that populates from a sqlDataSource

I added a textBox and a button to input company name in a textBox and click the button to search. Once the row with company is found I want to update it, but when I click update in this row, the gridview displays all of the rows, and instead of the one from the search results, the first row at the top is displayed in update template.

The GridView first is populated from a static sqlDataSource (EditDistributor), that displays all of the columns in a table.

                SelectCommand="SELECT [company], [d_address], [country], [phone], Email, [ddate], [distr_id] FROM [distributors]" 
                UpdateCommand="UPDATE [distributors] SET [company] = @company, [d_address] = @d_address, [country] = @country, [phone] = @phone, Email = @email, [ddate] = @ddate WHERE [distr_id] = @distr_id">


Then in this click event I call a StoredProcedure:

Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click

        EditDistributor.SelectCommandType = SqlDataSourceCommandType.StoredProcedure

Gridview Search Error


I want to give search functionality in grid view. To implement this i am following the below link


but I am getting following error

The name 'MSCD' does not exist in the current context

Iam using the following code

if (MSCD.Utilities.Validation.IsDateTime(_newValue) == true)


                    DateTime dtValue = DateTime.Parse(_newValue);

                    _newValue = sfield + " " + _operator + " #" + dtValue.ToShortDateString() + "#";


Can anyone tell me why iam getting this error and what is the use of this MSCD.Utilities.Validation sysntax

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.


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