Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Databound Field From Gridview

Status
Not open for further replies.

raphael232

Programmer
Joined
Jun 9, 2006
Messages
51
Location
GB
Hi, i'm making an attempt at the article at Everything works a treat except that instead of using the datakey (as done in the article) i wish to use a field bounded to the gridview. I have tried doing:

Code:
For i As Integer = 0 To GridView1.Rows.Count - 1
    Dim chkAuthorise As CheckBox = CType(GridView1.Rows(i).FindControl("chkAuthorise"), CheckBox)
    Dim strTitle As String = DataBinder.Eval(GridView1.Rows(i).DataItem, "Title")

    If chkAuthorise.Checked Then
        lblSummary.Text &= "<li>" & strTitle & "</li>"
    End If
Next

To return the Title field but it keeps returning an empty string.

Appreciate it if someone could tell me what i am doing wrong.

Thanks
 
Use the RowDataBound event to loop through the gridview rows. It fires as each row is bound. Then you can simply access the values of the cells in that event.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top