Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Getting the value of a single cell in a datagrid

Getting the value of a single cell in a datagrid

Scheduled Pinned Locked Moved Visual Basic
questioncsharp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raysot777
    wrote on last edited by
    #1

    This is definitely Monday. I have an Excel worksheet that I am trying to get the contents of a DataGrid into. worksheet.Cells(2, 1) = StatusGrid.Column(1).Item(1) It would be nice if it were that simple. I was thiking of casting the datagrid into a table, but for reasons that are too cosmic to go into here, that is not possible at this time. So... the question is.. Using VB.Net (ASP), how in the world does one reference a Cell in a datagrid?

    S 1 Reply Last reply
    0
    • R raysot777

      This is definitely Monday. I have an Excel worksheet that I am trying to get the contents of a DataGrid into. worksheet.Cells(2, 1) = StatusGrid.Column(1).Item(1) It would be nice if it were that simple. I was thiking of casting the datagrid into a table, but for reasons that are too cosmic to go into here, that is not possible at this time. So... the question is.. Using VB.Net (ASP), how in the world does one reference a Cell in a datagrid?

      S Offline
      S Offline
      StylezHouse
      wrote on last edited by
      #2

      Close... StatusGrid.Items(1).Cells(1).Text()

      R 1 Reply Last reply
      0
      • S StylezHouse

        Close... StatusGrid.Items(1).Cells(1).Text()

        R Offline
        R Offline
        raysot777
        wrote on last edited by
        #3

        So far so good. That works on bound columns beautifully. Some of the other columns are rendered as Template columns. How would you perform the same operation on a column as defined here: Thanks again in advance for all of your help. -Ray

        A 1 Reply Last reply
        0
        • R raysot777

          So far so good. That works on bound columns beautifully. Some of the other columns are rendered as Template columns. How would you perform the same operation on a column as defined here: Thanks again in advance for all of your help. -Ray

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          Depends on whats in em.. If you have textbox's etc in them, you'll want to look at the controls collection of the cell, or use the FindControl method to just grab it.

          R 1 Reply Last reply
          0
          • A Anonymous

            Depends on whats in em.. If you have textbox's etc in them, you'll want to look at the controls collection of the cell, or use the FindControl method to just grab it.

            R Offline
            R Offline
            raysot777
            wrote on last edited by
            #5

            That seems to be the problem: //-- This works well: (just a bound column) For i = 0 To StatusGrid.Items.Count - 1 worksheet.Cells(i + 2, 1) = StatusGrid.Items(i).Cells(1).Text() Next //-- but when I use: (Tries to get a Template Column) For i = 0 To StatusGrid.Items.Count - 1 worksheet.Cells(i + 2, 2) = StatusGrid.Items(i).FindControl("lblDateAdded").ToString() Next ...the appropriate cell text reads: "System.Web.UI.WebControls.Label" It doesn't seem to be finding the lblDateAdded control using the above method. Do I need to be casting it? -- modified at 18:55 Monday 3rd October, 2005

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups