datagrid: can't get read text from a cell programmatically

Discussion in 'ASP .Net' started by David, Jul 3, 2003.

  1. David

    David Guest

    In the event handler for ItemCommand, I am trying to read text of cells in
    the row programmatically, but can't get it working.

    //this is what I have in InitializeComponent
    this.dgList.ItemCommand += new
    System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgList_Command);

    //this is the event handler.
    private void dgList_Command(object sender, DataGridCommandEventArgs e)
    {
    if(e.CommandName == "View")
    {
    Response.Write(e.Item.Cells.Count);
    Response.Write(e.Item.Cells[0].Text);
    }
    }

    When the button is command button is pressed, I am trying to read the text
    in the first cell (e.Item.Cells[0].text), but nothing is showing up. I do
    see that it recognizes eItem.Cells.Count and shows the number of cells as
    expected. But I do I read the contents of the cell in that row?

    PS: I don't have Visual Studio 03 installed. Could this be a bug?
    David, Jul 3, 2003
    #1
    1. Advertising

  2. David

    David Guest

    Here is a follow up comment.

    I can set the text, and read what I set, but still can't read what is
    initially there. What is going on here?????


    //this line shows nothing. Why? The text is there.
    Response.Write(e.Item.Cells[0].Text);

    //this line will set the text of the first cell to "Good"
    e.Item.Cells[0].Text="Good";

    //And this line outputs "Good"
    Response.Write(e.Item.Cells[0].Text);
    David, Jul 3, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.rcn.com
    Replies:
    1
    Views:
    9,618
    Chris Smith
    Jul 12, 2004
  2. John Dalberg
    Replies:
    4
    Views:
    764
  3. andric
    Replies:
    0
    Views:
    421
    andric
    Feb 1, 2008
  4. David

    Can't read the content of a cell programmatically

    David, Jul 3, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    105
    David
    Jul 3, 2003
  5. Empire City
    Replies:
    3
    Views:
    385
    Empire City
    Apr 30, 2004
Loading...

Share This Page