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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help GridView DataItem

Status
Not open for further replies.

Esoteric

ISP
Feb 10, 2001
93
US
Sort of a Newbie to .net here, having difficulties with my control, argh. Here is the code.

Code:
Dim row As GridViewRow
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strstorename As String
For Each row In GridView1.Rows
  chkSelected = row.FindControl("ITEMCHECKBOX")
  If (Not chkSelected Is Nothing) Then
    If chkSelected.Checked Then
     'strstorename = CType(row.FindControl("CUSTNAME"), TextBox).Text
     'strstorename = (row.DataItem("CUSTNAME").ToString
      strstorename = DataBinder.Eval(row.DataItem, "CUSTNAME").ToString()
      Label2.Text = "The store name is <b>" & strstorename & "</b>"
     Else
      Label2.Text = ""
    End If
  Else
    Label2.Text = "Control Not Found"
  End If
Next

So my control is found and working, not getting the control not found. However my GridView1 is bound to an SQL statement. here is that snip
Code:
 <asp:BoundField DataField="CUSTNAME" HeaderText="CUSTNAME" SortExpression="CUSTNAME" />

How can I get that information into my routine. Puzzled at what I am missing here.
 
Figured it out finally. row.Cells(1).text That is what I was missing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top