Solved

Retrieve data from a specific cell in Gridview

Posted on 2008-06-17
2
3,025 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now