select the row of the datagrid whose value is same as one of the value of row of datagrid

hellow all,

 I have a datagrid which is bound to the ordertable,so all the orderdetails are shown on the page load.

but my requirement is that,i have a textbox and a search button,when the user enter the order number in the text box and click on the search button the datagrid should show that record whose order number is entered by the user n most imp that the record may be in the 65th or 34th row of the datagrid,i wants to put it in the first row.

how to do it.

5/15/2007 1:55:42 PM 72751 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 15

If there's a reason you can't filter down to just the one row, you'll have to come up with some paging algorithm that will let you break the grid until you get the desired results.
5/15/2007 2:27:55 PM
Modify your sql statement to select the order where the ordernumber==textbox.text and rebind the data grid when you click the button.
Easy as pie
5/15/2007 2:29:40 PM

Hi Dear,

You can use DataView to filter the records in DataTable..try this code

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click

Dim dv As DataView = CType(DataGrid1.DataSource, DataView)

dv.RowFilter = "OrderNumberColumnName=" + txtSearch.Text

DataGrid1.DataSource = dv


End Sub

but you have to remember one thing...when page load first are geeting all the orders from DataBase..and binding it to the DataGrid...and in case of search you are geeting DataGrid.DataSource...Filtering it using DataView and again bind this DataView with DataSource.........At this stage....Where is your Actual data that come from the Database.?????

if you also maintain the all records that come from the database then you have to save them in Session.......


Like you have to use following code when you are getting data from database

dim dtOrders as DataTable = GetOrderDataTable() ' Your function that get Order Records from Database

Session("OrdersDetail") = dtOrders


and on Search Button Click Event....Get the DataTable From Session...and Create DataView from this dataTable and Fileter the Records and then bind the dataview with DataGrid...

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click

Dim dv As DataView = CType(Session("OrdersDetail"), DataTable).DefaultView

dv.RowFilter = "OrderNumberColumnName=" + txtSearch.Text

DataGrid1.DataSource = dv


End Sub



Best Regards,

Muhammad Akhtar Shiekh

Please remember to mark the appropriate replies as answer after your question is solved, thanks
5/15/2007 2:45:51 PM

Similar Artilces:

DataGrid: Insert a new row value in footer based on the selected row value
Hi guys         I need immediate help with the datagrid taht I am making. I have about 9 rows and with edit template item and a footer template for the new row that can be inserted in the db.   When someone hits the insert link in a row in the datagrid say its row 2 with OrgId = 10, I was the new row that comes as a footer row for the insert to populate orgId 10, leving the rest of the colums emtry for the user to fill in. But one column of this new row I want it to be populated with the value that was selected upon htting insert. I hope I didnt c...

Copying row values from one DataGrid to another datagrid
Hi,I have a scenario as follows.I have two datagrid and a button.the first datatgrid is loaded with data ( there are some column with drop down list). I have a check box column the fisrt datgrid.User can check or uncheck the check box. After doing this user will click on the button.Now I want to add all the rows from datagrid one where the check box is checked to the second datagrid. I also want to make sure the drop downlist values are also loaded in the second  gridoutline struct is as  followsif checkbox.checked then   copy row from first datagrid to second d...

Referencing BoundField Datafield values of Datagrid row when button on same row is selected????
Given the Gridview below: When I select the button "Rate" and fall into this code: How can I reference "carriercode" and other . Apparently selecting the button does not select the row. I've tried find control, and everything returns that I must reference and instance of the object.  CommandArgument is being sent corrently. If the button were a buttonfield I would have no problem getting the row index, but Im having problems because the button is an runat server button. snip...  Protected Sub PendingGridView_RowCommand(ByVal sender As Object, By...

How to add values to DataGrid row by row
How do I add values to a DataGrid row by row without using a DataSource? Is this possible? Or should I just use a table? my code works like this: BoundColumn Col1 Add Col1 to DataGrid1 for every str in stringarray { Add New Row DataGrid1 with Col1 = str } Thanks. may be following URLwill help you Arvind Well, DataGrid was found not to make you do it the old way as in ASP 3.0. You can still get a datasource like datatable and then loop in it and display all the data row by row, is this what you want ? ...

How to select a field value from a selected row from a DataGrid in order to use it as a parameter
I am working on a web application, and I have two DataGrids.  Then end-User is supposed to select a row from one of the grids, and the event should select a key from that row in order to use it as a parameter to fill the other DataGrid.  I have been trying to do so, but I dont work the same way as I used to do it in windows applications.   I would appreciate any suggestions,   Thanks. Is there some code we can look at? I've done similar things and I've never had any problem with them. In the first grid have a select column, when it is clicked you can catch the Sel...

how do i go/setfocus to a datagrid row, based on an outside selection e.g. selected value from dropdownlist
I can retirieve the string value out of the selectedvalue from a dropdownList using that value -> how do I set focus to the row in a datagrid with the same unique value and update the datagrid??. private void ddlBook_SelectedIndexChanged(object sender, System.EventArgs e) { fails, cant convert string to int ---> dataGrig.SelectedIndex = ddlBook.SelectedValue; dataGrid.PreRender(); // trying to refresh here to new focused row } Hi, you need to identify the row in the datagrid that has the value you've selected in the dropdownlist and ...

How do I get a column value when I select a row in datagrid?
Hi, I use a DataGrid and I have a "Edit" butto on each line. When I click the button I'm able to get the index of that row, but now I want to get a value of a field. I have a field named "Ref." with some IDs and each ID has its label, and I want to get the value of the label of the selected row. Since I have the index of the row, how can I find that label?To get the index of the row:int index = Convert.ToInt16(e.Item.ItemIndex.ToString());I know that in .Net 2005 to get the value I want on a gridview I use to do:((Label)GridView1.Rows[index].FindControl("Label1")).Text; but in .Net 2003 usin...

Reading the cell value of the Selected Datagrid Row...
I currently have a datagrid setup so that when a user clicks on a certain row, an action is performed against that row (pretty standard setup). But instead of reading the e.Item.ItemIndex property and using that number to identify the row, I would like to use a numeric value displayed within one of the cells of the datagrid row, or I would at least like to be able to access a cell value from the currently selected row. I have tried using e.Item.Cell(1) but get an error: BC30456: 'Cell' is not a member of 'System.Web.UI.WebControls.DataGridItem'. Any advise would be greatly appreciat...

Modify control values in row of Datagrid during edit
Hi! I have a datagrid, in which the first column holds a dropdownlist (during an edit). I would like to be able to modify the contents of the other columns based on what a user selects in the dropdownlist. So far I have set the "OnSelectedIndexChanged" event to a procedure called "ChangeDefaultValues" as follows: <EditItemTemplate> <asp:dropdownlist DataSource='<%# dsCurrentLocation.DefaultView %>' DataTextField="CurrentLocation" DataValueField = "CurrentLocation" ID="CurrentLocation" runat="server" OnS...

Retrieve cell value from selected datagrid row
I am trying to retrieve the record number when a user clicks on the "Select" field in a datagrid.   Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged' RecNo is an auto number field        Dim RecNo As Integer        RecNo = e.Row.Cells.Item(0)I get the following error Row is not a member of system.eventargs What am I doing wrong?   Refer example in below link

New row in datagrid: Old values are overwritten instead of a new row appears
First post from a not so experienced VS.NET/VB programmer I am writing a short piece of code that allows users of the program to enter some data in textboxes and then by clicking on a button, allow them to add the information they put in the textboxes to a datagrid. The first time they press this button, it shows perfectly in the datagrid on the form, but the 2nd time it only updates the first row instead of adding a new row.By doing some searches on Google, I found out that I am not using the right code, but I can't find how to do it correctly. I hope to get an answer here.Below you see...

Select particular row and take the value of particular column selelcted row and pass the value to another page
Hi,  i'm making one webform where i'm displaying datafileds  through GridView. GridView has 6 columns like name, Id, & etc with two icons. one is email icon and another one is mobile icon. In those there are three Buttons(name, email, mobile). When the user clicks on email then it takes the values of email and it forwards to another page and mobile too. Here i can set and pass the  value of email, i'm able to pass the values when i click on email icon and it is passing successfully to another page but it is playing the same action whe...

Hello, I'd like to set the value of a DropDownList based on a value of another field in the DataGrid.These values are from different <columns>.The first value shows up just fine in the "BoundColumn".But, the one I want to set in the TemplateColumn isn't working.Can someone take a look at my code snippet and see what I'm doing wrong? The Control I'm trying to set is called "ddlBenchStart".I'm trying to get the value from the "BenchStart" column.The values in "BenchStart" would be "Bench" or "Start&...

CommandArgument value gets lost when selecting same row in DataGrid
I'm pretty much an expert at using the GridView control, but I am working on enhancing an older application using ASP.NET 1.1 and has a DataGrid control.  I am binding data to this DataGrid and have a LinkButton in one of the columns, which fires the DataGrid's ItemCommand event.  When the button is clicked, I am displaying detailed information pertaining to the selected item in the DataGrid.  Since it's possible to have multiple rows in the DataGrid, I want to highlight the row whose button I clicked so I know which row the corr...

Web resources about - select the row of the datagrid whose value is same as one of the value of row of datagrid -

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 295 ...

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 11 Jul 2012 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 12/22/2015 3:12:40 PM