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,



12/20/2005 6:45:35 PM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 36

Is there some code we can look at? I've done similar things and I've never had any problem with them.
12/20/2005 7:53:34 PM

In the first grid have a select column, when it is clicked you can catch the SelectedIndexChanged event.  From this you can get the datakey value for that row and can populate the other datagrid.

<asp:DataGrid id="MyDataGrid" runat="server"

         <HeaderStyle BackColor="#aaaadd">

         <SelectedItemStyle BackColor="Yellow">


                 HeaderText="Select Item"







Sub BindGrid()
            MyDataGrid.DataSource = CartView
            MyDataGrid.DataKeyField = "ItemID"
End Sub 'BindGrid

Sub MyDataGrid_Select(sender As Object, e As EventArgs)
    dim itemID as Integer = MyDataGrid.DataKeys( MyDataGrid.SelectedIndex)
    ' You have the ItemID with which you can Bind the other grid.

End Sub 'MyDataGrid_Select

Hope this helps.

12/20/2005 8:11:17 PM
why don't you create a session variable to hold the itemID and use that in your second grid. I am guessing you have tied your grid to a sqldatasource that is executing a query that uses the itemID. So just make sure it uses the Session variable that you are creating that has the itemID in it.
12/20/2005 8:18:44 PM

Similar Artilces:

How do i: On DataGrid Row Selection, Change a value in Specific Field using Code
Hi, There's probably a very simple answer to this one but cant find it anywhere! I have a Data Grid Listing Incidents that have been posted by other users of a site. Fields include IncidentID, IncidentPoster, IncidentTimeDate, IncidentText, IncidentChecked, IncidentCheckedTimeDate I want a manager to be able to click select on a Row and the Field "IncidentChecked" to be changed from False to True, and also in "IncidentCheckedTimeDate" a Timestamp to be entered into the database. The DataGrid already shows all Rows that have IncidentChecked as False so he should ...

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

Problem in Using DropDownList Control to select a selected row of SqlDataSource that is under GridView Control
Hi all,In my SQL Server Management Studio Express, I have a database "ChemDatabase" that has a table "LabData"  formatted in the following way: SampleID int PRIMARY KEY, SampleName nvarchar(25), ChemicalName, nvarchar(25), Concentration decimal(6.2) with 5 rows of records in this .dbo table. In my Visual Web Developer Express, I created a website "RPD-TCE" for extracting a row of record from the LabData table by using a DropDownList, a GridView and a SqlDataSource.  I want to click DropDownList to list one number of S...

Selecting value in one field then causes value in another field to be selected.
I have a web form which contains a date field, the date is populated using a DatePicker which is Javascript based. The form also has a drop down box containing 3 values. What I want to do is when a date has been selected that this will cause the dropdown list value to change to dated which is one of its 3 values. i.e. when the date field is not blank then the value will be selected in the dropdown. What I also want to happen is when the date has been selected and the dropdown value is dated then the date field and the dropdown field will be set to read only.Anyone any ideas how to this usin...

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

Iwant to select a row and column in gridview with select radiobutton. but No checked change event.below put a button .if click that button to seleced row values will select
I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page im using this code .but im getting one column in that row. but i want all columns in that selected row so plz repla...

Using datagrid selected value to input to parameter in stored procedure
could someone please let me know if i am declaring the parameter wrong or have the wrong VB CODE.  I receive my 3 column headers in my datagrid but the parameter isn't doing anything STORED PROCEDURE CREATE PROCEDURE USP_Machcusidsearch @Machcusid nvarchar  OUTPUTAS SELECT     dbo.Machine.machcustomID, dbo.Problem.ProblemDesc, dbo.Request.ReqDateFROM         dbo.Machine INNER JOIN                      dbo.Request O...

How to use GridView row's Key selected for Delete as select parameter for another datasource
I'm not sure if the subject title makes sense, but it wasn't too easy to describe what I'm trying to do in one sentence! When a user clicks on the delete link in a GridView row, I want to run a stored proc, using the Key of the selected record as the parameter for the stored proc. I then want to programatically access the result of the stored proc (it'll be an integer value) for code-behind use. I wrote out a few steps to help me figure out what I need to do: 1) Get the value of PersonnelID (the DataKey) from the selected row in the GridView2) Set that Perso...

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

Selecting a value from a gridview selected row
i am trying to select a value from a selected row in a gridview. the value i want to select is "workordernumber"  i have the gridview displaying a list of work orders.  the list changed depending on whether or not the person has chosen to view open, closed or all work orders.  if i am view just the open or closed work orders it is obviously not showing every single work order number and there are some gaps in there.  when i try to select the value of the work order number cell with the select button it is acting kinda funky.  it is selecting the index value instead o...

Custom Parameter for Select Paramters
SELECT     ArticleID, ArticleTitle, ArticleDate, Published, PublishDate, PublishEndDateFROM         UserArticlesWHERE     (ArticleDate >= PublishDate) AND (ArticleDate <= PublishEndDate) When I use the above on a GridView I get nothing.  Using SQL manager it works great. I don't know how to pass the value of the ArticleDate field as a default parameter or I think that's what I don't know how to do. I am trying to create a app that I can set the dates an article will appear on a page...

How Select one dropdownlist value using down arrows corresponding other dropdownlist value are select
I am using two dropdownlist box.One is used for country selection. other one is used for state selection.I am using dropdown selectedindexchanged event. when i click country dropdownlist corresponding state is selected in state dropdownlist box. How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.R.Karthikeyan   kartmca: How select the country in country dropdownlist using down arrow keys at the same time corresponding state is select in state dropdown list.Generally, we don't implmenet...

problem with selected text field and selected value field in check box list
Hi! i have a  problem with check box list:here is the code for binding the check box list with sqldatasource  SqlDataSource1.SelectCommand = "select vcentrolno,inttpaperno from tabmarksdetails where vcbunchno='" & strBunchNo & "'"  chkEnrolNos.DataBind()say now my chkEnrolNos consist of data in this way:vcentrolno        inttpaperno selected text   selected valueA11439            1A11439            2AR439    ...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

Web resources about - How to select a field value from a selected row from a DataGrid in order to use it as a parameter -

Parameter - Wikipedia, the free encyclopedia
A parameter (from the Ancient Greek παρά , "para", meaning "beside, subsidiary" and μέτρον , "metron", meaning "measure"), in its common meaning, ...

fb_source Parameter - Facebook-Entwickler
This document lists the complete list of values for the fb_source parameter that is returned with th...

Google Webmaster Tools Parameter Handling - Flickr - Photo Sharing!
You aren't signed in Sign In Help Home The Tour Sign Up Explore Explore Home Last 7 Days Interesting Popular Tags Calendar Most Recent Uploads ...

Cat 8: TIA performance standards committee chairman previews parameters of forthcoming twisted-pair cable ...
Category 8, the next-generation twisted-pair cabling specification, is still in development, but the outlook looks quite positive that it will ...

Philippine president asks for 'parameters' of Mayon Volcano tours
Philippine president asks for 'parameters' of Mayon Volcano tours People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, Apr, May, ...

Alternatives to boolean parameters
... ) { PrintLine ( item . Name ); if ( printDetails ) { PrintLine ( item . Description ); } } } Aha! Now can see that the boolean parameter ...

Exporting Error (Error in Parameter...: Apple Support Communities
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability ...

Apple tech monitors device aging, adjusts operating parameters to ensure optimal performance
... describing a method of monitoring the aging of a device's electronics, comparing the data with a global average and modifying operating parameters ...

Is it poor programming practice to pass parameters as objects?
... a free, community-powered network of 100+ Q&A sites . Risser asked: So, we've got a guy who likes to write methods that take Objects as parameters, ...

Parameter Short Film Competition sponsored by Grolsch
Grolsch presents Parameter The A.V. Club Short Film Competition Please Enter Your Date of Birth Ineligible entry Enter For people over the age ...

Resources last updated: 12/13/2015 7:31:08 AM