Link to home
Start Free TrialLog in
Avatar of vrao92
vrao92

asked on

Reading gridview value

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
Avatar of Deathrace
Deathrace
Flag of India image


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();
        }
Avatar of vrao92
vrao92

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of M3mph15
M3mph15
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vrao92

ASKER

Thank you..I tried and it worked.