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. GridView Template Field Value

GridView Template Field Value

Scheduled Pinned Locked Moved C#
help
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.
  • J Offline
    J Offline
    jashimu
    wrote on last edited by
    #1

    Hi All, I am trying to get in my gridView there are two template fields. I need to get those Rows[0] and Cell[0] value. Please help.

    "if you don't know ask"

    L P 2 Replies Last reply
    0
    • J jashimu

      Hi All, I am trying to get in my gridView there are two template fields. I need to get those Rows[0] and Cell[0] value. Please help.

      "if you don't know ask"

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      object jashimusValue = dataGridView[0 , 0].Value;

      Didn't test it on the compiler though.

      Bastard Programmer from Hell :suss:

      1 Reply Last reply
      0
      • J jashimu

        Hi All, I am trying to get in my gridView there are two template fields. I need to get those Rows[0] and Cell[0] value. Please help.

        "if you don't know ask"

        P Offline
        P Offline
        Peric Zeljko
        wrote on last edited by
        #3

        Hello, I have created small program with one button "OK" and "DataGridVew1" with one column "Messages", for storing text messages. When I start the program , i enter some messages to "DataGridView1" and when I click "OK Button" ,MessageBox shows with text of textmessage in first row. For unswering to your question look this sample code:

        void Button1Click(object sender, EventArgs e)
        {
        // TODO: Implement Button1Click
        //
        // when you click on button OK,
        // program shows MessageBox with value of
        // DataGridView1[0,0]
        // in this programming language column goes first then row!
        // DataGridView[column,row], so watch out for mistakes,
        // allso in some programming languages the first row and column
        // does not have indexes [0,0] but [1,1]

        int row = 0;
        int column = 0;
        string message;
        //
        // first and allways
            // check is there any value in dataGridView1
        // beacouse null value can sometimes make problem
            // 
        if (dataGridView1\[column,row\].Value == null)
        { 
          dataGridView1\[column,row\].Value = "Empty";
        }
        		
        message = dataGridView1\[column,row\].Value.ToString();
        MessageBox.Show(message);
        						
        }
        

        I think that the answer to your question is obvious. All the best, Peric Zeljko periczeljkosmederevo@yahoo.com

        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