Accessing a cell value for a record

Last post 12-07-2006 1:24 PM by sh0ck. 3 replies.

Sort Posts:

  • Accessing a cell value for a record

    12-06-2006, 3:08 PM
    • Loading...
    • sh0ck
    • Joined on 11-27-2006, 11:30 AM
    • Posts 8

    Hello everyone,

    I'm ripping my hair out right now, I've read lots of articles on the subject of DataSets, DataTables, DataViews and the DataReader command.  I am however unable to find my solution which should be rather simple.  I am using VS.net, SQL Server 2000 and VB.Net for my code-behind.

    I have a grid view that is populated by a basic stored procedure.  The last column of my gridview is a template field that I use to display a person's email address.  I have used the mailto: function to allow the user to send an email through their mail program. 

    I am now attempting to create a button that will "Email All" the users. The button should insert all the records' email addresses and populate them in the send to fields.  My problem is that I cannot figure out to get the value from the TableAdapter or the GridView or even from the database itself.

    So if someone could direct in the appropriate place or explain how to use the DataReader to retrieve the value of a cell in a TableAdapter, it would be much appreciated.
     

     Thanks,

    Éric
     

  • Re: Accessing a cell value for a record

    12-06-2006, 10:14 PM
    • Loading...
    • augustwind
    • Joined on 07-21-2002, 11:16 PM
    • Garland, TX
    • Posts 4,069
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    It's a matter of iterating through all the rows, grabbing the email addresses and then emailing.

    If you're using a TableAdapter, and it's unchanged since populating the Gridview, you can iterate through the TableAdapter, or the Gridview. If you are using a DataReader to populate the Gridview, you would need to iterate through the rows of the Gridview itself.

    You weren't totally clear - how exactly are you populating the Gridview?

    David Wier
    MVP/MCP/ASPInsider
    ASPNet101.com - where to look first!
    iWrite Pro - doc/rtft to HTML/One Click PDF & much more
  • Re: Accessing a cell value for a record

    12-07-2006, 10:15 AM
    • Loading...
    • sh0ck
    • Joined on 11-27-2006, 11:30 AM
    • Posts 8

    Hi David,

     Thanks for responding.

     
    You actually clarified a lot for me and I think I'm on the right path.  For clarification sake, here is what I am doing:

     1. Populating a table adapter by a stored procedure with 5 session parameters.

    2. Displaying a gridview based on the table adapter

    3. **this is where I'm at** Click a link button which allows the user to Email All the contacts displayed in the gridview

    --

     Right now I have 3 questions:

     1) How can I count the amount of rows in a table adapter?

     2) How can I check if contacts is actually filing itself?

    contacts = contactsAdapter.GetDataSummaryViewContact(Session("sInstCode"), Session("sOfficer"), Session("sCategory"), Session("sInstName"), Session("sLastName"))

    3) I'm trying to iterate through the table adapter's rows like this:

     

            Dim i As Integer
            For i = 0 To contacts.Rows.Count - 1
    
                contactRow = contacts.Rows(i)
                Label1.Text = contactRow.Email.ToString
            Next

     
    I'll continue to search for an answer but any help you could provide will surely help.

    Thanks again,

    Éric
     

  • Re: Accessing a cell value for a record

    12-07-2006, 1:24 PM
    • Loading...
    • sh0ck
    • Joined on 11-27-2006, 11:30 AM
    • Posts 8
    And by the way, I am populating my GridView by an object data source.
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter