Solved

Reading gridview value

Posted on 2009-05-07
4
275 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
  • 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to check mis-spellings in a select SQL 2 39
Aspx calendar pop up control 3 28
CSS for Popup in ASP.NET 4 19
asp.net repeater 2 16
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
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…
This video teaches users how to migrate an existing Wordpress website to a new domain.

726 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