Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading gridview value

Posted on 2009-05-07
4
Medium Priority
?
293 Views
Last Modified: 2013-11-08
I want to read a column value in MS gridview control using FOR loop. I will basically comparing the value in each row for that column and then I will have to put that row in edit mode if the values of that row match with what I have in a variable.

How would I do that? Please help
0
Comment
Question by:vrao92
[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
4 Comments
 
LVL 9

Expert Comment

by:Deathrace
ID: 24327869

Got the solution, see below

Cells[2] .. where 2 is the column index which we need.

for (int i = 0; i < GridViewHW.Rows.Count; i++)
        {
            string value = GridViewHW.Rows[i].Cells[2].ToString();
        }
0
 

Author Comment

by:vrao92
ID: 24327998
I converted this code to Vb.net and this is what I have
  Dim sValue As String
        For i As Integer = 0 To GridView3.Rows.Count - 1
            sValue = GridView3.Rows(i).Cells(4).ToString()
        Next

And in my imeediate window I typed in ?svalue and I get this.. System.Web.UI.WebControls.DataControlFieldCell
but not the value
0
 
LVL 6

Accepted Solution

by:
M3mph15 earned 2000 total points
ID: 24333609
Hi, Try sValue = GridView3.Rows(i).Cells(4).Text.ToString()
0
 

Author Comment

by:vrao92
ID: 24335380
Thank you..I tried and it worked.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

650 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