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. C#
  4. finding the contents of a cell in a datagrid

finding the contents of a cell in a datagrid

Scheduled Pinned Locked Moved C#
sales
3 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.
  • S Offline
    S Offline
    steve_rm
    wrote on last edited by
    #1

    Hello, I have a datagrid with a list of customers. I want to be able to click on the row then be able to display the customer number which is in the first column of that row. I have code for finding the row number: rowNumber = grdDisplayCustomers.CurrentRowIndex; But how do find out the customer number which is in the first column of that row. Many thanks in advance, Steve

    C D 2 Replies Last reply
    0
    • S steve_rm

      Hello, I have a datagrid with a list of customers. I want to be able to click on the row then be able to display the customer number which is in the first column of that row. I have code for finding the row number: rowNumber = grdDisplayCustomers.CurrentRowIndex; But how do find out the customer number which is in the first column of that row. Many thanks in advance, Steve

      C Offline
      C Offline
      Colin Mc
      wrote on last edited by
      #2

      Have you tried using a hyperlink column? Not sure if this will work for you but you could have column 1 with text 'View Details' and have this as a link to another page displaying the customer info. Something like this... private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e){ //cast to dataGrid as that is what you are using DataGrid grid = (DataGrid)sender; //redirect to page you display customer info in passing customer number from column 1 (column 0 is your hyperlink column) string page = "newpage.aspx?id=" + grid.Items[grid.SelectedIndex].Cells[1].Text; Response.Redirect(page,true); } Just an idea! Colin

      1 Reply Last reply
      0
      • S steve_rm

        Hello, I have a datagrid with a list of customers. I want to be able to click on the row then be able to display the customer number which is in the first column of that row. I have code for finding the row number: rowNumber = grdDisplayCustomers.CurrentRowIndex; But how do find out the customer number which is in the first column of that row. Many thanks in advance, Steve

        D Offline
        D Offline
        DougW48
        wrote on last edited by
        #3

        grdDisplayCustomers[grdDisplayCustomers.CurrentRowIndex,0];

        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