Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to bind table values in gridview row cells(one column name from table). I used this code to increment cell index. But its not working.



VB
While (dr.Read() = True)
       If (dr.HasRows = True) Then

           Dim j As String
           Dim i As Integer = 1
           j = dr(0).ToString
           gv1.Rows(0).Cells(i).Value = j
           i = i + 1

       End If
   End While


if anybody know please help me.

thanks in advance
Posted

Try this;
C#
Dim iTest AsInteger
Dim j As String
Dim i As Integer = 1
gv1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
j = dr(0).ToString
gv1.Rows(0).Cells(i).Value = j
i = i + 1
iTest = gv1.SelectedRows(0).Index + 1
gv1.Rows(iTest).Selected = True
 
Share this answer
 
 
Share this answer
 
Debug your code, put a beakpoint at the first line and watch for the value of your variables. You will see where the problem is.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900