Solved

Retrieve data from a specific cell in Gridview

Posted on 2008-06-17
2
3,030 Views
Last Modified: 2013-12-16
I have a Gridview connected to a datasource in my C# code. I now wish to retrieve some data from this GW without asking the DB. The data sould be collected from a certain row when a checkbox has been triggered. In the example below I was able to retrieve the data corresponding to a key in the GW. The question is: How do I retrieve data from the other colums which are not keys in the GW?

Buddah bless
string tmp = ((long)GridView1.DataKeys[((GridViewRow)cb.NamingContainer).RowIndex][1]).ToString();

Open in new window

0
Comment
Question by:jide85
2 Comments
 
LVL 22

Accepted Solution

by:
prairiedog earned 250 total points
ID: 21803295
Assume i is the index of the row that is triggered by the checkbox, and j is the specific cell that you are interested in. You can get the value like this:
GridViewRow gvr = GridView1.Rowsii];
string tmp = gvr.Cells[j-1].Text              // the index of the cells starts from 0
0
 
LVL 16

Assisted Solution

by:burakiewicz
burakiewicz earned 250 total points
ID: 21803322
if you know what row was hit, then you could use
GridView1.Rows[intRow].Cells[myCell].Text
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question