Solved

Reading gridview value

Posted on 2009-05-07
4
269 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

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

A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

791 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