Hide a Gridview column but use the value in that column when the row is selected.

I need to retrieve a column from my database but do not want to display it in the gridview.  However, I need to be able to show that information later in the application.  I am using the wizard control.  I believe I can use the DataKeyValues property of the gridview but can't figure out how to write the code to get the value of the cell in that column when the row is selected so it can be referenced later.  I am using VB.  Thanks for your help!!
0
McGuire
1/26/2007 10:26:18 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
1013 Views

Similar Articles

[PageSpeed] 44

Found the answer.  Here it is in case anyone else needs it:


            Dim strMyValue As String = gridviewName.DataKeys(gridviewName.SelectedRow.RowIndex).Values("ColumnName")

Smile

0
McGuire
1/26/2007 11:28:37 PM
Hi im not quite sure what you mean by "using later in the application" but to have a column holding (for example) an id the below code demonstrates how to: 
    "BrandDataSource"  runat="server" TypeName="Site.BLL.Shop.Brand"  DataObjectTypeName="Site.BLL.Shop.Brand"  InsertMethod="InsertBrand" SelectMethod="GetAllBrands" DeleteMethod="DeleteBrand" UpdateMethod="UpdateBrand" OnDeleted="BrandDataSource_Deleted">
    
    "BrandID" Type="Int32">
    
    

    "GridView1" runat="server" AutoGenerateColumns="False" BackColor="White"
        BorderColor="#999999" DataKeyNames="BrandID">
                   
            "false" DataField="BrandID"  HeaderText="BrandID" SortExpression="BrandID">
            "Name" HeaderText="Name" SortExpression="Name">
            
    

 The reason the code looks a bit odd is because i just pulled it straight out of a project.

 Hope that helps

0
dimeric
1/26/2007 11:32:00 PM

Woops please ignore my post i just copyied and pasted it a touch wrong!

 Glad you found the answer

0
dimeric
1/26/2007 11:33:55 PM
Reply:

Similar Artilces:

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

Can not get datakeyname value of selected row using template column in gridview
I have a gridview with a template column with an image button when it is clicked I wanted to get the datakeyname value of this line item this code is executing under the Public Sub dgcases_OnRowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)If e.CommandName = "imageswap" ThenDim index As Integer = Convert.ToInt32(e.CommandArgument)Dim lineitem As String = CType(Me.dgcases.DataKeys(index).Value, String)EndifI get an error of input string not in the correct format. Any help would be great. Thank you.   Public Sub dgcases_OnRowCommand(ByVal sender As Obje...

Hide Gridview column based on the column value
I have a grid which i bind with values from Database. I have events to edit and update the grid. I am not using SqlDatasource to connect to DB. Rather i am doing the updating of the grid Programmatically. The Grid is populated based on a dropdown selection Gridview has 4 columns, LID(item template column) ,LVal (Item Template and an Edit Item template column), Lookupid (Item Template and an Edit Item template column) and "Edit" link 4 of 10 Dropdown selections have values in Column 3 (lookupid), rest dont. When they dont have values i want to hide that column 3. Of course i can ...

GridView.Rows(Column=ID_PK) to GridView.Rows(Column=DropDownListTeamplteField)
Hi Guys,I wonder how I can assign the PrimaryKey in each GridView Row to the template field in the same row. whereas the template field is filled with a dropdownlist thatshould show the values for retrieved in a different table through the GridView Row primary key (which serves as the SELECT parameter to get these values) The GridView looks like this:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="C_ID" DataSourceID="GetC_IDs"> <Columns> <asp:BoundField D...

I want to select a row and column in gridview using radiobutton in gridview
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...

I want to select a row and column in gridview using radiobutton in gridview #2
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...

Change / hide gridview column value based on value in different colum in same row
Hi allI've come across a unusual problem that I can't work out.  I'm using VB by the way.  I have a gridview that is populated from a "suggestions" database and contains 6 databound columns - ID, Firstname, Surname, Department, Suggestion, HideName. The gridview pulls the details from the database and displays all the values as should be. When a user adds data to the databse they have a option to hide their identity by placing a tick in a checkbox. This all gets updated without any issues. The Firstname and Username get automatically populated from their User ...

Using the column value of another row in computed column.
Hi fellow PBer's, I am having trouble figuring out how to reference the column value of a specific row. In the computed columns property sheet, I select the "More" button to modify the columns expression. The way I understand help is to specify columnname[integer] where integer is the number of rows (positive or negative) relative to the current row (ie Total[-1] would be the value of the Total column in the previous row. However, I cant seem to get this to compile in the modify expression painter. I am using PB5.0 on Win95. Any help would be greatly appreciated. ...

Values of Selected Row of GridView by Column Name
Hello I want to fill several textboxes by clicking the SELECT link of a gridview. The event SelectedIndexChanged works fine in this case but my problem is that I have to get the values by Cells Number (row.Cells[5].Text). Is there a possibility to get the Cell value of a selected Row via the headertext or the bound database column text like it is possible using insert oder update statements programmatically (ObjectDataSource.InsertParameter["columnname"].DefaultValue).This would it make much easier if I reorder the columns in de gridview cause in this case the values written in the textbox...

How to get gridview selected row column value?
I have a gridview with columns "ref" "title" "date"I want to get the value of the selected item text from title.i have tried gridview.selectedItem.text but obviously i need to specify what column to get the text from but i dont know howPlease helpThanksMatt  The columns are numbered from 0 on up, so column 1 is index 0 on the cells! protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { string test = GridView1.SelectedRow.Cells[0].Text; }http://incendy.spaces.live.com...

exporting a gridview control with selected rows and columns
Hey I would liket o export only the data not the headers or the controller(edit, delete, etc) how would i go about doing so. This si my code that allows me to export in the first place!Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click   GridView1.AllowPaging = False GridView1.PageSize = 100 GridView1.DataSource = "datasourcePullInst" 'Place your datasource (datatable/dataset) 'GridView1.DataBind() Response.Clear() Response.Buffer = TrueResponse.AddHeader("Content-Disposition", "attachment...

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

How to read the invisible column selected row value in Gridview
I can read the row value with Label1.Text = GVList.SelectedRow.Cells(1).Text but it won't read the value from the column which is not visible in grid.any idea?  see the following forum http://forums.asp.net/t/1052026.aspx     Put that field which is normally in the hidden column into your GridView.DataKeyNames property instead. This way, the value can simply be retrieved through the GridView.DataKeys collection.Thanks, EdMicrosoft MVP - ASP/ASP.NET Even you advice will work, but a while ago, i figured out even easy way to read. Many thanks, Hi,  &n...

Gridview -- Need to Retrieve a Selected Column Value from a Row
(I could've sworn that I ran into this before, but because this GridView is displaying a VIEW/JOIN, I can't find the reference type that I apparently need.) I have a Gridview from a VIEW/JOIN and (for the sake of discussion) the items that I need to provide UPDATE capability for cannot be updated from the Grid, so I am attempting to pull up the Row of the real Table (not the JOIN) in a DetailsView, for which I need the identity of the particular Selected row,  For example:           When the user clicks on "Select" for this second row, ...

Web resources about - Hide a Gridview column but use the value in that column when the row is selected. - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 1/12/2016 8:34:03 AM