Solved

Retrieve data from a specific cell in Gridview

Posted on 2008-06-17
2
3,031 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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

732 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