How To Check Value Displyed In Grid View With The Control(s) id !!!!! RRS feed

  • Question


    Hey there all,

    i got the values i wanted through Data Reader but they are now showned in Grid View but i want to check the Values going in Grid View With My Contols(s) id please let me know if any one of you know this to do

    here is my code:-


    b = ""

    a = DropDownList1.SelectedIndex

    If a = "0" Then

    b = "Table_name1"

    ElseIf a = "1" Then

    b = "Table_name2"

    End If

    Dim DBConn As New SqlConnection("Server=.;Password=pwd;Persist Security Info=False;User ID=sa;Initial Catalog=DBName;Data Source=.")

    Dim DBCmd As New SqlCommand

    Dim DR As SqlDataReader


    DBCmd = New SqlCommand("SELECT Table_name3," & b & " FROM Table_name where Coloum_Name ='Value", DBConn)

    DR = DBCmd.ExecuteReader()

    Me.GridView1.DataSource = DR


    Me.GridView1.AutoGenerateColumns = True



     Till here My code is working Fine and showing the Values in a Grid View but My Main Problem Start's here


    DBCmd = New SqlCommand("SELECT id," & b & " FROM lang where pgid='Change Pin'", DBConn)

    DR = DBCmd.ExecuteReader()

    If DR.Read() Then

    End If

    If GridView1.Rows.Item(0).Cells.Count() - 1 Then

    If DR.GetString(DR.GetOrdinal("id")).Contains("sChPi_lbl0") Then

    Me.sChPi_lbl0.Text = DR(b.Trim.ToString)

    End If



    If DR.GetString(DR.GetOrdinal("id")).Contains("sChPi_lbl1") Then

    Me.sChPi_lbl1.Text = DR(b.Trim.ToString)

    End If

    If Me.sChPi_lbl2.ID = DR.GetString(DR.GetOrdinal("sChPi_lbl2")) Then

    Me.sChPi_lbl2.Text = DR(b.Trim.ToString)

    End If


    If Me.sChPi_lbl3.ID = DR.GetString(DR.GetOrdinal("sChPi_lbl3")) Then

    Me.sChPi_lbl3.Text = DR(b.Trim.ToString)

    End If


    If Me.sChPi_btn1.ID = DR.GetString(DR.GetOrdinal("sChPi_btn1")) Then

    Me.sChPi_btn1.Text = DR(b.Trim.ToString)

    End If


    I am trying to get the values once again to check the id of My Control(s) as all the changes will be done on there basis

    thus  i am First Checking in If Loop wheter the label id i have is same if yes then in second line i change the text of that label and so on till the finall Button


    Please help to solve this problem... thanx in advance....

    Wednesday, April 9, 2008 1:27 PM